at/batch broken
    YONETANI Tomokazu 
    qhwt+dfly at les.ath.cx
       
    Sun Jan  7 00:31:20 PST 2007
    
    
  
On Sun, Jan 07, 2007 at 05:06:05PM +0900, YONETANI Tomokazu wrote:
> I'm attaching the sample code again.
*blush* here you are.
Cheers.
/*
 * usage:
 * $ gcc -W -Wall at.c
 * $ su
 * # chown root a.out; chmod u+s a.out
 * # exit
 * $ ./a.out
 */
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#define CHECK(expr) \
if ((expr) != 0) \
  err(1, #expr)
int
main()
{
	uid_t real_uid, effective_uid;
	int fd;
	real_uid = getuid();
	effective_uid = geteuid();
	CHECK(setreuid(effective_uid, real_uid));
	CHECK(setreuid(real_uid, effective_uid));
	fd = open("/etc/hosts", O_RDONLY);
	CHECK(setreuid(effective_uid, real_uid));
	close(fd), fd = -1;	/* move this above the previous line */
	CHECK(setreuid(real_uid, effective_uid));
	printf("uid %d, euid %d\n", getuid(), geteuid());
	CHECK(setreuid(effective_uid, real_uid));
	return 0;
}
    
    
More information about the Bugs
mailing list