[BACK]Return to id.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / id

Diff for /src/usr.bin/id/id.c between version 1.21 and 1.22

version 1.21, 2014/07/14 05:41:00 version 1.22, 2015/01/16 06:40:08
Line 29 
Line 29 
  * SUCH DAMAGE.   * SUCH DAMAGE.
  */   */
   
 #include <sys/param.h>  
   
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <grp.h>  #include <grp.h>
Line 39 
Line 37 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   #include <limits.h>
   
 void    current(void);  void    current(void);
 void    pretty(struct passwd *);  void    pretty(struct passwd *);
Line 200 
Line 199 
         struct passwd *pw;          struct passwd *pw;
         int cnt, ngroups;          int cnt, ngroups;
         uid_t uid, euid;          uid_t uid, euid;
         gid_t groups[NGROUPS], gid, egid, lastgid;          gid_t groups[NGROUPS_MAX], gid, egid, lastgid;
         char *prefix;          char *prefix;
   
         uid = getuid();          uid = getuid();
Line 221 
Line 220 
                 if ((gr = getgrgid(egid)))                  if ((gr = getgrgid(egid)))
                         (void)printf("(%s)", gr->gr_name);                          (void)printf("(%s)", gr->gr_name);
         }          }
         if ((ngroups = getgroups(NGROUPS, groups))) {          if ((ngroups = getgroups(NGROUPS_MAX, groups))) {
                 for (prefix = " groups=", lastgid = (gid_t)-1, cnt = 0;                  for (prefix = " groups=", lastgid = (gid_t)-1, cnt = 0;
                     cnt < ngroups; prefix = ", ", lastgid = gid) {                      cnt < ngroups; prefix = ", ", lastgid = gid) {
                         gid = groups[cnt++];                          gid = groups[cnt++];
Line 238 
Line 237 
 void  void
 user(struct passwd *pw)  user(struct passwd *pw)
 {  {
         gid_t gid, groups[NGROUPS + 1];          gid_t gid, groups[NGROUPS_MAX + 1];
         int cnt, ngroups;          int cnt, ngroups;
         uid_t uid;          uid_t uid;
         struct group *gr;          struct group *gr;
Line 249 
Line 248 
         (void)printf(" gid=%u", pw->pw_gid);          (void)printf(" gid=%u", pw->pw_gid);
         if ((gr = getgrgid(pw->pw_gid)))          if ((gr = getgrgid(pw->pw_gid)))
                 (void)printf("(%s)", gr->gr_name);                  (void)printf("(%s)", gr->gr_name);
         ngroups = NGROUPS + 1;          ngroups = NGROUPS_MAX + 1;
         (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);          (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
         prefix = " groups=";          prefix = " groups=";
         for (cnt = 0; cnt < ngroups;) {          for (cnt = 0; cnt < ngroups;) {
Line 268 
Line 267 
 group(struct passwd *pw, int nflag)  group(struct passwd *pw, int nflag)
 {  {
         int cnt, ngroups;          int cnt, ngroups;
         gid_t gid, groups[NGROUPS + 1];          gid_t gid, groups[NGROUPS_MAX + 1];
         struct group *gr;          struct group *gr;
         char *prefix;          char *prefix;
   
         if (pw) {          if (pw) {
                 ngroups = NGROUPS + 1;                  ngroups = NGROUPS_MAX + 1;
                 (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);                  (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
         } else {          } else {
                 groups[0] = getgid();                  groups[0] = getgid();
                 ngroups = getgroups(NGROUPS, groups + 1) + 1;                  ngroups = getgroups(NGROUPS_MAX, groups + 1) + 1;
         }          }
         prefix = "";          prefix = "";
         for (cnt = 0; cnt < ngroups;) {          for (cnt = 0; cnt < ngroups;) {

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22