Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/coreutils/id.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 36  enum { Line 36  enum {
36  #endif  #endif
37  };  };
38    
39  static int print_common(unsigned id,  static int print_common(unsigned id, const char *name, const char *prefix)
  char* FAST_FUNC bb_getXXXid(char *name, int bufsize, long uid),  
  const char *prefix)  
40  {  {
  const char *name = bb_getXXXid(NULL, 0, id);  
   
41   if (prefix) {   if (prefix) {
42   printf("%s", prefix);   printf("%s", prefix);
43   }   }
# Line 65  static int print_common(unsigned id, Line 61  static int print_common(unsigned id,
61    
62  static int print_group(gid_t id, const char *prefix)  static int print_group(gid_t id, const char *prefix)
63  {  {
64   return print_common(id, bb_getgrgid, prefix);   return print_common(id, gid2group(id), prefix);
65  }  }
66    
67  static int print_user(uid_t id, const char *prefix)  static int print_user(uid_t id, const char *prefix)
68  {  {
69   return print_common(id, bb_getpwuid, prefix);   return print_common(id, uid2uname(id), prefix);
70  }  }
71    
72  /* On error set *n < 0 and return >= 0  /* On error set *n < 0 and return >= 0
# Line 123  int id_main(int argc UNUSED_PARAM, char Line 119  int id_main(int argc UNUSED_PARAM, char
119   /* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/   /* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
120   /* Don't allow more than one username */   /* Don't allow more than one username */
121   opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"   opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
122   USE_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");   IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
123   opt = getopt32(argv, "rnugG" USE_SELINUX("Z"));   opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
124    
125   username = argv[optind];   username = argv[optind];
126   if (username) {   if (username) {
127   struct passwd *p = getpwnam(username);   struct passwd *p = xgetpwnam(username);
  if (!p)  
  bb_error_msg_and_die("unknown user %s", username);  
128   euid = ruid = p->pw_uid;   euid = ruid = p->pw_uid;
129   egid = rgid = p->pw_gid;   egid = rgid = p->pw_gid;
130   } else {   } else {
# Line 181  int id_main(int argc UNUSED_PARAM, char Line 175  int id_main(int argc UNUSED_PARAM, char
175   }   }
176   } else if (n < 0) { /* error in get_groups() */   } else if (n < 0) { /* error in get_groups() */
177   if (!ENABLE_DESKTOP)   if (!ENABLE_DESKTOP)
178   bb_error_msg_and_die("cannot get groups");   bb_error_msg_and_die("can't get groups");
179   else   else
180   return EXIT_FAILURE;   return EXIT_FAILURE;
181   }   }

Legend:
Removed from v.983  
changed lines
  Added in v.984