bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] getlogin


From: Neal H Walfield
Subject: [patch] getlogin
Date: Thu, 16 Aug 2001 15:46:40 +0200
User-agent: Mutt/1.3.18i

Using getlogin is prone to a variety of problems.  This patch fixes that
by avoiding getlogin altogether:

2001-08-16  Neal H Walfield  <address@hidden>

        * libparted/libparted.c (ped_init): Use getpwuid and geteuid,
        not getlogin.


--- libparted.c.orig    Thu Aug 16 15:00:19 2001
+++ libparted.c Thu Aug 16 15:11:54 2001
@@ -122,8 +122,11 @@ done_disk_types ()
 int
 ped_init ()
 {
-       if (getlogin())
-               initgroups (getlogin(), 0);
+       struct passwd *user;
+
+       user = getpwuid(geteuid());
+       if (user)
+               initgroups(user->pw_name, 0);
 
 #ifdef ENABLE_NLS
        bindtextdomain (PACKAGE, LOCALEDIR);

Attachment: pgpNVosPUH_gL.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]