Date: Wed, 5 Feb 2003 15:10:54 -0600 From: "Anoop Ranganath" <anoop@ranganath.com> To: <freebsd-current@freebsd.org> Subject: tmpfile breakage on setuid executables Message-ID: <00e201c2cd5b$14f31c30$0c02040a@ranganath>
next in thread | raw e-mail | index | archive | help
The problem reared it's ugly head when maildrop started mishandling mesasges. Here is what I've tracked it down to: I've used the code at the bottom of this message to isolate this bug. The summary is that when I compile the code as root, and then make it setuid (chmod u+s a.out) and then try to run it as a user, the tmpfile() fails. If I run it as root, it works fine. Conversely, I can give user ownership of the executable, and then run it as user, and it works great, but if fails for root. Again this is only with the setuid bit set. My system is FreeBSD 5.0-RELEASE (GENERIC) #0: Thu Jan 16 22:16:53 GMT 2003 Thanks, Anoop #include <stdlib.h> #include <stdio.h> int main( void ) { FILE *stream; stream = tmpfile(); if( stream != NULL ) { printf( "File number is %d.\n", fileno( stream ) ); fclose( stream ); return EXIT_SUCCESS; } return EXIT_FAILURE; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00e201c2cd5b$14f31c30$0c02040a>