View | Details | Raw Unified
Collapse All | Expand All

(-) coreutils-5.97/lib/userspec.c (-7 / +15 lines)
 Lines 105-111    Link Here 
static char const *
static char const *
parse_with_separator (char const *spec, char const *separator,
parse_with_separator (char const *spec, char const *separator,
		      uid_t *uid, gid_t *gid,
		      uid_t *uid, gid_t *gid,
		      char **username, char **groupname)
		      char **username, char **groupname, bool numeric)
{
{
  static const char *E_invalid_user = N_("invalid user");
  static const char *E_invalid_user = N_("invalid user");
  static const char *E_invalid_group = N_("invalid group");
  static const char *E_invalid_group = N_("invalid group");
 Lines 159-165    Link Here 
  if (u != NULL)
  if (u != NULL)
    {
    {
      pwd = getpwnam (u);
      if(numeric)
	pwd = NULL;
      else
      	pwd = getpwnam (u);
      if (pwd == NULL)
      if (pwd == NULL)
	{
	{
	  bool use_login_group = (separator != NULL && g == NULL);
	  bool use_login_group = (separator != NULL && g == NULL);
 Lines 195-201    Link Here 
  if (g != NULL && error_msg == NULL)
  if (g != NULL && error_msg == NULL)
    {
    {
      /* Explicit group.  */
      /* Explicit group.  */
      grp = getgrnam (g);
      if(numeric)
	grp = NULL;
      else
        grp = getgrnam (g);
      if (grp == NULL)
      if (grp == NULL)
	{
	{
	  unsigned long int tmp;
	  unsigned long int tmp;
 Lines 243-253    Link Here 
char const *
char const *
parse_user_spec (char const *spec, uid_t *uid, gid_t *gid,
parse_user_spec (char const *spec, uid_t *uid, gid_t *gid,
		 char **username, char **groupname)
		 char **username, char **groupname, bool numeric)
{
{
  char const *colon = strchr (spec, ':');
  char const *colon = strchr (spec, ':');
  char const *error_msg =
  char const *error_msg =
    parse_with_separator (spec, colon, uid, gid, username, groupname);
    parse_with_separator (spec, colon, uid, gid, username, groupname, numeric);
  if (!colon && error_msg)
  if (!colon && error_msg)
    {
    {
 Lines 259-265    Link Here 
      char const *dot = strchr (spec, '.');
      char const *dot = strchr (spec, '.');
      if (dot
      if (dot
	  && ! parse_with_separator (spec, dot, uid, gid, username, groupname))
	  && ! parse_with_separator (spec, dot, uid, gid, username, groupname, numeric))
	error_msg = NULL;
	error_msg = NULL;
    }
    }
 Lines 284-290    Link Here 
      char *tmp;
      char *tmp;
      tmp = strdup (argv[i]);
      tmp = strdup (argv[i]);
      e = parse_user_spec (tmp, &uid, &gid, &username, &groupname);
      e = parse_user_spec (tmp, &uid, &gid, &username, &groupname, false);
      free (tmp);
      free (tmp);
      printf ("%s: %lu %lu %s %s %s\n",
      printf ("%s: %lu %lu %s %s %s\n",
	      argv[i],
	      argv[i],
(-) coreutils-5.97/lib/userspec.h (-1 / +2 lines)
 Lines 2-10    Link Here 
# define USERSPEC_H 1
# define USERSPEC_H 1
# include <sys/types.h>
# include <sys/types.h>
#include <stdbool.h>
const char *
const char *
parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
		 char **username_arg, char **groupname_arg);
		 char **username_arg, char **groupname_arg, bool numeric);
#endif
#endif
(-) coreutils-5.97/src/chgrp.c (-4 / +15 lines)
 Lines 71-76    Link Here 
  {"silent", no_argument, NULL, 'f'},
  {"silent", no_argument, NULL, 'f'},
  {"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
  {"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
  {"verbose", no_argument, NULL, 'v'},
  {"verbose", no_argument, NULL, 'v'},
  {"numeric", no_argument, NULL, 'n'},
  {GETOPT_HELP_OPTION_DECL},
  {GETOPT_HELP_OPTION_DECL},
  {GETOPT_VERSION_OPTION_DECL},
  {GETOPT_VERSION_OPTION_DECL},
  {NULL, 0, NULL, 0}
  {NULL, 0, NULL, 0}
 Lines 79-91    Link Here 
/* Return the group ID of NAME, or -1 if no name was specified.  */
/* Return the group ID of NAME, or -1 if no name was specified.  */
static gid_t
static gid_t
parse_group (const char *name)
parse_group (const char *name, bool numeric)
{
{
  gid_t gid = -1;
  gid_t gid = -1;
  struct group *grp = NULL;
  if (*name)
  if (*name)
    {
    {
      struct group *grp = getgrnam (name);
      if(!numeric)
        grp = getgrnam (name);
      if (grp)
      if (grp)
	gid = grp->gr_gid;
	gid = grp->gr_gid;
      else
      else
 Lines 129-134    Link Here 
                         ownership of a symlink)\n\
                         ownership of a symlink)\n\
"), stdout);
"), stdout);
      fputs (_("\
      fputs (_("\
  -n, --numeric          treats OWNER and GROUP as numeric by default. User '0'\n\
                         would be root rather then username '0'.\n\
"), stdout);
      fputs (_("\
      --no-preserve-root do not treat `/' specially (the default)\n\
      --no-preserve-root do not treat `/' specially (the default)\n\
      --preserve-root    fail to operate recursively on `/'\n\
      --preserve-root    fail to operate recursively on `/'\n\
"), stdout);
"), stdout);
 Lines 193-199    Link Here 
  chopt_init (&chopt);
  chopt_init (&chopt);
  while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL))
  while ((optc = getopt_long (argc, argv, "HLPRcfhvn", long_options, NULL))
	 != -1)
	 != -1)
    {
    {
      switch (optc)
      switch (optc)
 Lines 246-251    Link Here 
	case 'v':
	case 'v':
	  chopt.verbosity = V_high;
	  chopt.verbosity = V_high;
	  break;
	  break;
	
	case 'n':
	  chopt.numeric = true;
	  break;
	case_GETOPT_HELP_CHAR;
	case_GETOPT_HELP_CHAR;
	case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
	case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
 Lines 299-305    Link Here 
    {
    {
      char *group_name = argv[optind++];
      char *group_name = argv[optind++];
      chopt.group_name = (*group_name ? group_name : NULL);
      chopt.group_name = (*group_name ? group_name : NULL);
      gid = parse_group (group_name);
      gid = parse_group (group_name, chopt.numeric);
    }
    }
  if (chopt.recurse & preserve_root)
  if (chopt.recurse & preserve_root)
(-) coreutils-5.97/src/chown-core.c (+1 lines)
 Lines 57-62    Link Here 
  chopt->force_silent = false;
  chopt->force_silent = false;
  chopt->user_name = NULL;
  chopt->user_name = NULL;
  chopt->group_name = NULL;
  chopt->group_name = NULL;
  chopt->numeric = false;
}
}
extern void
extern void
(-) coreutils-5.97/src/chown-core.h (+4 lines)
 Lines 64-69    Link Here 
  /* The name of the group to which ownership of the files is being given. */
  /* The name of the group to which ownership of the files is being given. */
  char *group_name;
  char *group_name;
  /* Whether the supplied OWNER/GROUP combo should be treated as numeric or
     defaultly as name then numeric. */
  bool numeric;
};
};
void
void
(-) coreutils-5.97/src/chown.c (-3 / +12 lines)
 Lines 78-83    Link Here 
  {"silent", no_argument, NULL, 'f'},
  {"silent", no_argument, NULL, 'f'},
  {"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
  {"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
  {"verbose", no_argument, NULL, 'v'},
  {"verbose", no_argument, NULL, 'v'},
  {"numeric", no_argument, NULL, 'n'},
  {GETOPT_HELP_OPTION_DECL},
  {GETOPT_HELP_OPTION_DECL},
  {GETOPT_VERSION_OPTION_DECL},
  {GETOPT_VERSION_OPTION_DECL},
  {NULL, 0, NULL, 0}
  {NULL, 0, NULL, 0}
 Lines 110-115    Link Here 
                         ownership of a symlink)\n\
                         ownership of a symlink)\n\
"), stdout);
"), stdout);
      fputs (_("\
      fputs (_("\
  -n, --numeric          treats OWNER and GROUP as numeric by default. User '0'\n\
                         would be root rather then username '0'.\n\
"), stdout);
      fputs (_("\
      --from=CURRENT_OWNER:CURRENT_GROUP\n\
      --from=CURRENT_OWNER:CURRENT_GROUP\n\
                         change the owner and/or group of each file only if\n\
                         change the owner and/or group of each file only if\n\
                         its current owner and/or group match those specified\n\
                         its current owner and/or group match those specified\n\
 Lines 195-201    Link Here 
  chopt_init (&chopt);
  chopt_init (&chopt);
  while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL))
  while ((optc = getopt_long (argc, argv, "HLPRcfhvn", long_options, NULL))
	 != -1)
	 != -1)
    {
    {
      switch (optc)
      switch (optc)
 Lines 238-244    Link Here 
	    char *u_dummy, *g_dummy;
	    char *u_dummy, *g_dummy;
	    const char *e = parse_user_spec (optarg,
	    const char *e = parse_user_spec (optarg,
					     &required_uid, &required_gid,
					     &required_uid, &required_gid,
					     &u_dummy, &g_dummy);
					     &u_dummy, &g_dummy, chopt.numeric);
	    if (e)
	    if (e)
	      error (EXIT_FAILURE, 0, "%s: %s", quote (optarg), e);
	      error (EXIT_FAILURE, 0, "%s: %s", quote (optarg), e);
	    break;
	    break;
 Lines 260-265    Link Here 
	  chopt.verbosity = V_high;
	  chopt.verbosity = V_high;
	  break;
	  break;
	case 'n':
	  chopt.numeric = true;
	  break;
	case_GETOPT_HELP_CHAR;
	case_GETOPT_HELP_CHAR;
	case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
	case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
	default:
	default:
 Lines 313-319    Link Here 
  else
  else
    {
    {
      const char *e = parse_user_spec (argv[optind], &uid, &gid,
      const char *e = parse_user_spec (argv[optind], &uid, &gid,
				       &chopt.user_name, &chopt.group_name);
				       &chopt.user_name, &chopt.group_name, chopt.numeric);
      if (e)
      if (e)
        error (EXIT_FAILURE, 0, "%s: %s", quote (argv[optind]), e);
        error (EXIT_FAILURE, 0, "%s: %s", quote (argv[optind]), e);