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

Diff for /src/usr.bin/getent/getent.c between version 1.19 and 1.20

version 1.19, 2018/09/26 16:26:37 version 1.20, 2018/09/26 16:39:19
Line 190 
Line 190 
 static int  static int
 group(int argc, char *argv[])  group(int argc, char *argv[])
 {  {
         int             i, rv = RV_OK;  
         struct group    *gr;          struct group    *gr;
           const char      *err;
           gid_t           gid;
           int             i, rv = RV_OK;
   
         setgroupent(1);          setgroupent(1);
         if (argc == 2) {          if (argc == 2) {
Line 199 
Line 201 
                         GROUPPRINT;                          GROUPPRINT;
         } else {          } else {
                 for (i = 2; i < argc; i++) {                  for (i = 2; i < argc; i++) {
                         const char      *err;                          gid = strtonum(argv[i], 0, GID_MAX, &err);
                         long long id = strtonum(argv[i], 0, UINT_MAX, &err);  
   
                         if (!err)                          if (!err)
                                 gr = getgrgid((gid_t)id);                                  gr = getgrgid(gid);
                         else                          else
                                 gr = getgrnam(argv[i]);                                  gr = getgrnam(argv[i]);
                         if (gr != NULL)                          if (gr != NULL)
Line 291 
Line 291 
 static int  static int
 passwd(int argc, char *argv[])  passwd(int argc, char *argv[])
 {  {
         int             i, rv = RV_OK;  
         struct passwd   *pw;          struct passwd   *pw;
           const char      *err;
           uid_t           uid;
           int             i, rv = RV_OK;
   
         setpassent(1);          setpassent(1);
         if (argc == 2) {          if (argc == 2) {
Line 300 
Line 302 
                         PASSWDPRINT;                          PASSWDPRINT;
         } else {          } else {
                 for (i = 2; i < argc; i++) {                  for (i = 2; i < argc; i++) {
                         const char      *err;                          uid = strtonum(argv[i], 0, UID_MAX, &err);
                         long long id = strtonum(argv[i], 0, UINT_MAX, &err);  
   
                         if (!err)                          if (!err)
                                 pw = getpwuid((uid_t)id);                                  pw = getpwuid(uid);
                         else                          else
                                 pw = getpwnam(argv[i]);                                  pw = getpwnam(argv[i]);
                         if (pw != NULL)                          if (pw != NULL)
Line 327 
Line 327 
 protocols(int argc, char *argv[])  protocols(int argc, char *argv[])
 {  {
         struct protoent *pe;          struct protoent *pe;
           const char      *err;
           int             proto;
         int             i, rv = RV_OK;          int             i, rv = RV_OK;
   
         setprotoent(1);          setprotoent(1);
Line 335 
Line 337 
                         PROTOCOLSPRINT;                          PROTOCOLSPRINT;
         } else {          } else {
                 for (i = 2; i < argc; i++) {                  for (i = 2; i < argc; i++) {
                         const char      *err;                          proto = strtonum(argv[i], 0, INT_MAX, &err);
                         long long id = strtonum(argv[i], 0, UINT_MAX, &err);  
   
                         if (!err)                          if (!err)
                                 pe = getprotobynumber((int)id);                                  pe = getprotobynumber(proto);
                         else                          else
                                 pe = getprotobyname(argv[i]);                                  pe = getprotobyname(argv[i]);
                         if (pe != NULL)                          if (pe != NULL)
Line 362 
Line 362 
 rpc(int argc, char *argv[])  rpc(int argc, char *argv[])
 {  {
         struct rpcent   *re;          struct rpcent   *re;
           const char      *err;
           int             rpc;
         int             i, rv = RV_OK;          int             i, rv = RV_OK;
   
         setrpcent(1);          setrpcent(1);
Line 370 
Line 372 
                         RPCPRINT;                          RPCPRINT;
         } else {          } else {
                 for (i = 2; i < argc; i++) {                  for (i = 2; i < argc; i++) {
                         const char      *err;                          rpc = strtonum(argv[i], 0, INT_MAX, &err);
                         long long id = strtonum(argv[i], 0, UINT_MAX, &err);  
   
                         if (!err)                          if (!err)
                                 re = getrpcbynumber((int)id);                                  re = getrpcbynumber(rpc);
                         else                          else
                                 re = getrpcbyname(argv[i]);                                  re = getrpcbyname(argv[i]);
                         if (re != NULL)                          if (re != NULL)
Line 397 
Line 397 
 services(int argc, char *argv[])  services(int argc, char *argv[])
 {  {
         struct servent  *se;          struct servent  *se;
           const char      *err;
           char            *proto;
           in_port_t       port;
         int             i, rv = RV_OK;          int             i, rv = RV_OK;
   
         setservent(1);          setservent(1);
Line 405 
Line 408 
                         SERVICESPRINT;                          SERVICESPRINT;
         } else {          } else {
                 for (i = 2; i < argc; i++) {                  for (i = 2; i < argc; i++) {
                         const char      *err;                          if ((proto = strchr(argv[i], '/')) != NULL)
                         long long       id;  
                         char *proto = strchr(argv[i], '/');  
   
                         if (proto != NULL)  
                                 *proto++ = '\0';                                  *proto++ = '\0';
                         id = strtonum(argv[i], 0, UINT_MAX, &err);                          port = strtonum(argv[i], 0, IPPORT_HILASTAUTO, &err);
                         if (!err)                          if (!err)
                                 se = getservbyport(htons((u_short)id), proto);                                  se = getservbyport(htons(port), proto);
                         else                          else
                                 se = getservbyname(argv[i], proto);                                  se = getservbyname(argv[i], proto);
                         if (se != NULL)                          if (se != NULL)

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20