[Pkg-shadow-commits] r2646 - in upstream/trunk: . libmisc
Nicolas FRANÇOIS
nekral-guest at alioth.debian.org
Sat Apr 11 16:23:21 UTC 2009
Author: nekral-guest
Date: 2009-04-11 16:23:21 +0000 (Sat, 11 Apr 2009)
New Revision: 2646
Modified:
upstream/trunk/ChangeLog
upstream/trunk/libmisc/chowntty.c
upstream/trunk/libmisc/getgr_nam_gid.c
Log:
* libmisc/getgr_nam_gid.c: Added support for NULL argument.
* libmisc/chowntty.c: Reuse getgr_nam_gid(), and get rid of atol().
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2009-04-11 16:08:00 UTC (rev 2645)
+++ upstream/trunk/ChangeLog 2009-04-11 16:23:21 UTC (rev 2646)
@@ -1,3 +1,8 @@
+2009-04-11 Nicolas François <nicolas.francois at centraliens.net>
+
+ * libmisc/getgr_nam_gid.c: Added support for NULL argument.
+ * libmisc/chowntty.c: Reuse getgr_nam_gid(), and get rid of atol().
+
2009-04-11 Peter Vrabec <pvrabec at redhat.com>
* libmisc/find_new_gid.c, libmisc/find_new_uid.c: For system
Modified: upstream/trunk/libmisc/chowntty.c
===================================================================
--- upstream/trunk/libmisc/chowntty.c 2009-04-11 16:08:00 UTC (rev 2645)
+++ upstream/trunk/libmisc/chowntty.c 2009-04-11 16:23:21 UTC (rev 2646)
@@ -2,7 +2,7 @@
* Copyright (c) 1989 - 1994, Julianne Frances Haugh
* Copyright (c) 1996 - 2001, Marek Michałkiewicz
* Copyright (c) 2003 - 2005, Tomasz Kłoczko
- * Copyright (c) 2007 - 2008, Nicolas François
+ * Copyright (c) 2007 - 2009, Nicolas François
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,6 @@
void chown_tty (const struct passwd *info)
{
- char *group; /* TTY group name or number */
struct group *grent;
gid_t gid;
@@ -60,18 +59,11 @@
* ID. Otherwise, use the user's primary group ID.
*/
- group = getdef_str ("TTYGROUP");
- if (NULL == group) {
- gid = info->pw_gid;
- } else if ((group[0] >= '0') && (group[0] <= '9')) {
- gid = (gid_t) atol (group);
+ grent = getgr_nam_gid (getdef_str ("TTYGROUP"));
+ if (NULL != grent) {
+ gid = grent->gr_gid;
} else {
- grent = getgrnam (group); /* local, no need for xgetgrnam */
- if (NULL != grent) {
- gid = grent->gr_gid;
- } else {
- gid = info->pw_gid;
- }
+ gid = info->pw_gid;
}
/*
Modified: upstream/trunk/libmisc/getgr_nam_gid.c
===================================================================
--- upstream/trunk/libmisc/getgr_nam_gid.c 2009-04-11 16:08:00 UTC (rev 2645)
+++ upstream/trunk/libmisc/getgr_nam_gid.c 2009-04-11 16:23:21 UTC (rev 2646)
@@ -49,6 +49,10 @@
long long int gid;
char *endptr;
+ if (NULL == grname) {
+ return NULL;
+ }
+
errno = 0;
gid = strtoll (grname, &endptr, 10);
if ( ('\0' != *grname)
More information about the Pkg-shadow-commits
mailing list