1

I passed the first check50 for Pset6 but still can't seem to get my server working after implementing indexes and load. I've been getting 403 errors whenever I request my homepage, as well as an invalid pointer error.

Using GDB, I was able to pinpoint the source of the error to here:

void list(const char* path)
{
    // ensure path is readable and executable
    if (access(path, R_OK | X_OK) == -1)
    {
        error(403);
        return;
    }

Can someone shed some light on the issue?

Thanks!

  • What means "invalid pointer error"? – DinoCoderSaurus Aug 8 '16 at 20:49
  • somehow the error went away, but I can't check my code using check50. It gives me an E_unknown error whenever I use it. I tried update50 but it didn't work – Chris Shi Aug 9 '16 at 0:46
  • 1
    somehow there's a problem with path, with it being /home/ubuntu/workspace/pset6/server, which results in a 404 or 403 error – Chris Shi Aug 9 '16 at 1:14
1

Your document root should be public. Path should be /home/ubuntu/workspace/pset6/public. You should call server as ./server public (assuming current working directory is ~/workspace/pset6). The reason server (the program) will run with server the argument (i.e. ./server server) is because the start() function only ensures the argument has execute permission. It is counting on you, the user, to make sure it is a directory.

This is implicitly indicated in the instructions:

Let’s try it out. Execute the below from within your own ~/workspace/pset6 directory so that the staff’s solution uses your own copy of public as its root.

~cs50/pset6/server public

If memory serves, the "E_unknown error" response from check50 indicates a time out on the check50 server. The only "remedy" is try again.

| improve this answer | |
  • 1
    Yup, I executed server exactly as ./server public, only to find through GDB that the path was /home/ubuntu/workspace/pset6/server – Chris Shi Aug 9 '16 at 18:11
  • 1
    hmmmm. since you're in gdb, I have to ask: did you do "run public" or "run server public"?. The former is correct. Put a break at 76 and inspect argv[1]. set a watchpoint on path. These are all the things I can think of without eyes-on. – DinoCoderSaurus Aug 9 '16 at 18:47
  • 1
    Ahh I get it now! I did use the "r ./server public" command – Chris Shi Aug 9 '16 at 18:49
  • 1
    Lemme check again and report back, thanks! – Chris Shi Aug 9 '16 at 18:50
  • 1
    That tip about gdb really helped me debug my code and find where the error was. Thank you so much for your help! – Chris Shi Aug 10 '16 at 2:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .