bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] id should not show selinux context when user is specified


From: Jim Meyering
Subject: Re: [PATCH] id should not show selinux context when user is specified
Date: Tue, 22 Apr 2008 18:22:10 +0200

Ondřej Vašík <address@hidden> wrote:
...
> +/* If true, id is used on specified user/group name */
> +static bool specified_name = false;
> +
>  /* The real and effective IDs of the user to print. */
>  static uid_t ruid, euid;
>  static gid_t rgid, egid;
> @@ -170,7 +173,7 @@ main (int argc, char **argv)
>        usage (EXIT_FAILURE);
>      }
>
> -  if (argc - optind == 1 && just_context)
> +  if ((specified_name = (argc - optind == 1)) && just_context)
>      error (EXIT_FAILURE, 0,
>          _("cannot print security context when user specified"));
>
> @@ -338,6 +341,6 @@ print_full_info (const char *username)
>      free (groups);
>    }
>  #endif /* HAVE_GETGROUPS */
> -  if (context != NULL)
> +  if (!specified_name && context != NULL)
>      printf (" context=%s", context);

Hi Ondřej,

Thank you for the patch.
Please change it so specified_name is local to main
and then just use it to avoid calling getcon.

Actually, I think this tiny change is enough:

-  if (selinux_enabled)
+  if (selinux_enabled && argc == optind)

...assuming you update the comment above that.

Also, for fixes like this, a new test case is required.
Do you feel like writing that?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]