aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2018-11-10 11:16:17 +0200
committerEli Zaretskii2018-11-10 11:16:17 +0200
commitd6b7b60cd0b4af8c0760589e132593b5c716d8ce (patch)
tree140b22b62d9456423ba283aaa2ce827b4d3a26b2 /src
parentffb4c76d99ba9d4f5a0d876c23b2837d31291141 (diff)
downloademacs-d6b7b60cd0b4af8c0760589e132593b5c716d8ce.tar.gz
emacs-d6b7b60cd0b4af8c0760589e132593b5c716d8ce.zip
Fix last change
* src/editfns.c (Fgroup_name): Fix the doc string. Move closer to the "group" functions. * src/w32.c (getgrgid): Return NULL if GID is not the group ID of the user of this Emacs session * test/src/editfns-tests.el (test-group-name): Rename from 'group-name'. Add tests for non-Posix hosts. Test error when the argument to group-name is invalid. * etc/NEWS: Fix wording of last added entry.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c33
-rw-r--r--src/w32.c4
2 files changed, 21 insertions, 16 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 15a0fa76597..8df4ed107e9 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1143,21 +1143,6 @@ of the user with that uid, or nil if there is no such user. */)
1143 return (pw ? build_string (pw->pw_name) : Qnil); 1143 return (pw ? build_string (pw->pw_name) : Qnil);
1144} 1144}
1145 1145
1146DEFUN ("group-name", Fgroup_name, Sgroup_name, 1, 1, 0,
1147 doc: /* If argument GID is an integer or a float, return the login name
1148of the group with that gid, or nil if there is no such GID. */)
1149 (Lisp_Object gid)
1150{
1151 struct group *gr;
1152 gid_t id;
1153
1154 CONS_TO_INTEGER (gid, gid_t, id);
1155 block_input ();
1156 gr = getgrgid (id);
1157 unblock_input ();
1158 return (gr ? build_string (gr->gr_name) : Qnil);
1159}
1160
1161DEFUN ("user-real-login-name", Fuser_real_login_name, Suser_real_login_name, 1146DEFUN ("user-real-login-name", Fuser_real_login_name, Suser_real_login_name,
1162 0, 0, 0, 1147 0, 0, 0,
1163 doc: /* Return the name of the user's real uid, as a string. 1148 doc: /* Return the name of the user's real uid, as a string.
@@ -1191,6 +1176,24 @@ Value is a fixnum, if it's small enough, otherwise a bignum. */)
1191 return INT_TO_INTEGER (uid); 1176 return INT_TO_INTEGER (uid);
1192} 1177}
1193 1178
1179DEFUN ("group-name", Fgroup_name, Sgroup_name, 1, 1, 0,
1180 doc: /* Return the name of the group whose numeric group ID is GID.
1181The argument GID should be an integer or a float.
1182Return nil if a group with such GID does not exists or is not known. */)
1183 (Lisp_Object gid)
1184{
1185 struct group *gr;
1186 gid_t id;
1187
1188 if (!NUMBERP (gid) && !CONSP (gid))
1189 error ("Invalid GID specification");
1190 CONS_TO_INTEGER (gid, gid_t, id);
1191 block_input ();
1192 gr = getgrgid (id);
1193 unblock_input ();
1194 return gr ? build_string (gr->gr_name) : Qnil;
1195}
1196
1194DEFUN ("group-gid", Fgroup_gid, Sgroup_gid, 0, 0, 0, 1197DEFUN ("group-gid", Fgroup_gid, Sgroup_gid, 0, 0, 0,
1195 doc: /* Return the effective gid of Emacs. 1198 doc: /* Return the effective gid of Emacs.
1196Value is a fixnum, if it's small enough, otherwise a bignum. */) 1199Value is a fixnum, if it's small enough, otherwise a bignum. */)
diff --git a/src/w32.c b/src/w32.c
index e643c421506..3eaa1279dd6 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2043,7 +2043,9 @@ getpwuid (unsigned uid)
2043struct group * 2043struct group *
2044getgrgid (gid_t gid) 2044getgrgid (gid_t gid)
2045{ 2045{
2046 return &dflt_group; 2046 if (gid == dflt_passwd.pw_gid)
2047 return &dflt_group;
2048 return NULL;
2047} 2049}
2048 2050
2049struct passwd * 2051struct passwd *