Article View: comp.security.misc
Article #426Re: Secure setuid mount program: A model!
From: Wietse Venema
Date: Thu, 20 Aug 1992 10:19
Date: Thu, 20 Aug 1992 10:19
26 lines
1134 bytes
1134 bytes
buzz@toxicavenger.bear.com (Buzz Moschetti) writes:
>Here is a "model" safe setuid program -- thanks to all who sent
>me mail with suggestions. Features include:
>[...]
>Can anyone add anything else? Are we secure yet?
Besides closing file descriptors > 2, you will want to make sure that
file descriptors 0,1,2 are open. Strange things can happen otherwise.
The following code fragment should do:
#include <sys/types.h>
#include <sys/stat.h>
...
struct stat st;
int i;
/* Make sure fd 0,1,2 are open. */
for (i = 0; i < 3; i++) {
if (fstat(i, &st) == -1 && open("/", 2) != i) {
perror("open /");
exit(1);
}
}
Technical Details
Message-ID:
<3746@wzv.win.tue.nl>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!tuegate.tue.nl!svin02!wzv!wietseReferences:
<BUZZ.92Aug19092622@toxicavenger.bear.com> <BUZZ.92Aug19163601@toxicavenger.bear.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!tuegate.tue.nl!svin02!wzv!wietse From: wietse@wzv.win.tue.nl (Wietse Venema) Newsgroups: comp.security.misc,alt.security Subject: Re: Secure setuid mount program: A model! Message-ID: <3746@wzv.win.tue.nl> Date: 20 Aug 92 10:19:09 GMT References: <BUZZ.92Aug19092622@toxicavenger.bear.com> <BUZZ.92Aug19163601@toxicavenger.bear.com> Organization: Eindhoven University of Technology, The Netherlands Lines: 26