ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/main.C
(Generate patch)

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.184 by root, Tue Jan 17 12:22:59 2006 UTC vs.
Revision 1.186 by root, Tue Jan 17 15:41:33 2006 UTC

209void rxvt_term::emergency_cleanup () 209void rxvt_term::emergency_cleanup ()
210{ 210{
211 if (cmd_pid) 211 if (cmd_pid)
212 kill (-cmd_pid, SIGHUP); 212 kill (-cmd_pid, SIGHUP);
213 213
214#ifdef UTMP_SUPPORT
215 privileged_utmp (RESTORE);
216#endif
217
218 delete pty; pty = 0; 214 delete pty; pty = 0;
219} 215}
220 216
221rxvt_term::~rxvt_term () 217rxvt_term::~rxvt_term ()
222{ 218{
600char **rxvt_environ; // startup environment 596char **rxvt_environ; // startup environment
601 597
602void 598void
603rxvt_init () 599rxvt_init ()
604{ 600{
601 uid_t uid = getuid ();
602 gid_t gid = getgid ();
603
604 // before doing anything else, check for setuid/setgid operation,
605 // start the helper process and drop privileges
606 if (uid != geteuid ()
607 || 1 //D
608 || gid != getegid ())
609 {
610#if PTYTTY_HELPER
611 rxvt_ptytty_server ();
612#else
613 rxvt_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n");
614#endif
615
616 // drop privileges
617#if HAVE_SETRESUID
618 setresgid (gid, gid, gid);
619 setresuid (uid, uid, uid);
620#elif HAVE_SETREUID
621 setregid (gid, gid);
622 setreuid (uid, uid);
623#elif HAVE_SETUID
624 setgid (gid);
625 setuid (uid);
626#endif
627
628 if (uid != geteuid ()
629 || gid != getegid ())
630 rxvt_fatal ("unable to drop privileges, aborting.\n");
631 }
632
605 rxvt_environ = environ; 633 rxvt_environ = environ;
606 634
607 /* 635 /*
608 * Save and then give up any super-user privileges 636 * Save and then give up any super-user privileges
609 * If we need privileges in any area then we must specifically request it. 637 * If we need privileges in any area then we must specifically request it.
715 } 743 }
716# endif 744# endif
717#endif 745#endif
718} 746}
719 747
720#ifdef UTMP_SUPPORT
721void
722rxvt_term::privileged_utmp (rxvt_privaction action)
723{
724 if (OPTION (Opt_utmpInhibit))
725 return;
726
727 rxvt_privileges (RESTORE);
728
729 if (action == SAVE)
730 pty->login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]);
731 else
732 pty->logout ();
733
734 rxvt_privileges (IGNORE);
735}
736#endif
737
738/*----------------------------------------------------------------------*/ 748/*----------------------------------------------------------------------*/
739/* 749/*
740 * window size/position calculcations for XSizeHint and other storage. 750 * window size/position calculcations for XSizeHint and other storage.
741 * if width/height are non-zero then override calculated width/height 751 * if width/height are non-zero then override calculated width/height
742 */ 752 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines