Ondřej Vašík <[EMAIL PROTECTED]> 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?


_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to