~ubuntu-branches/ubuntu/precise/torque/precise-updates

« back to all changes in this revision

Viewing changes to src/lib/Libutils/u_groups.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100517205646-yjsoqs5r1s9xpnu9
Tags: upstream-2.4.8+dfsg
ImportĀ upstreamĀ versionĀ 2.4.8+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "utils.h"
 
2
 
 
3
 
 
4
/**
 
5
 * getgrnam_ext - first calls getgrnam, and if this call doesn't return
 
6
 * anything, then it checks if the name is actually a group id by calling getgrgid
 
7
 * 
 
8
 * @param grp_name (I) - a string containing either the group's name or id
 
9
 * @return a pointer to the group, or NULL if the string represents neither
 
10
 * a valid group name nor a valid group id, or is NULL itself.
 
11
**/
 
12
 
 
13
 
 
14
struct group * getgrnam_ext( 
 
15
 
 
16
  char * grp_name ) /* I */
 
17
 
 
18
  {
 
19
 
 
20
  struct group * grp;
 
21
 
 
22
  /* bad argument check */
 
23
  if (grp_name == NULL)
 
24
    return NULL;
 
25
 
 
26
  grp = getgrnam( grp_name );
 
27
 
 
28
  /* if the group wasn't found by name, check if the name */
 
29
  /* was the group's id */
 
30
  if (grp == NULL)
 
31
    {
 
32
 
 
33
    if (isdigit(grp_name[0]))
 
34
      grp = getgrgid(atoi(grp_name));
 
35
 
 
36
    }
 
37
  
 
38
  return grp;
 
39
  
 
40
  }
 
41
 
 
42