Reading Questions

Remember to submit your answer to this question BEFORE the next class.

Read the following code fragment from page 145 of the Computer Security:

                    uid_t real_uid = getuid();
                    uid_t eff_uid = geteuid();

                    seteuid(real_uid);

                    f = fopen("/tmp/X", O_WRITE);
                    if (f != -1)
                        write_to_file(f);
                    else
                        fprintf(stderr, "Permission denied\n");

                    seteuid(eff_uid);
                

Can we change the third line code to

                    setuid(real_uid);
                

Why or why not?