[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gi
From: |
Anthony PERARD |
Subject: |
Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility |
Date: |
Tue, 24 Oct 2017 18:29:11 +0100 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
On Fri, Oct 20, 2017 at 02:38:21PM +0100, Ian Jackson wrote:
> +static bool os_parse_runas_uid_gid(const char *optarg)
> +{
> + unsigned long lv;
> + char *ep;
> + uid_t got_uid;
> + gid_t got_gid;
> + int rc;
> +
> + errno = 0;
> + lv = strtoul(optarg, &ep, 0); /* can't qemu_strtoul, want *ep==':' */
Should strtoul base be 10? If that matter.
> + got_uid = lv; /* overflow here is ID in C99 */
> + if (errno || *ep != ':' || got_uid != lv || got_uid == (uid_t)-1) {
> + return false;
> + }
> +
> + lv = 0;
> + rc = qemu_strtoul(ep + 1, 0, 0, &lv);
> + got_gid = lv; /* overflow here is ID in C99 */
> + if (rc || got_gid != lv || got_gid == (gid_t)-1) {
> + return false;
> + }
> +
> + user_uid = got_uid;
> + user_gid = got_gid;
> + return true;
> +}
> +
> /*
> * Parse OS specific command line options.
> * return 0 if option handled, -1 otherwise
> @@ -145,8 +175,10 @@ void os_parse_cmd_args(int index, const char *optarg)
> #endif
> case QEMU_OPTION_runas:
> user_pwd = getpwnam(optarg);
> - if (!user_pwd) {
> - fprintf(stderr, "User \"%s\" doesn't exist\n", optarg);
> + if (!user_pwd && !os_parse_runas_uid_gid(optarg)) {
> + fprintf(stderr,
> + "User \"%s\" doesn't exist (and is not <uid>.<gid>)\n",
The error message have not been update, I think it should be <uid>:<gid>
> + optarg);
> exit(1);
> }
> break;
With the error message fix:
Reviewed-by: Anthony PERARD <address@hidden>
--
Anthony PERARD
- Re: [Qemu-devel] [PATCH v5.1 3/8] xen: defer call to xen_restrict until just before os_setup_post, (continued)
- [Qemu-devel] [PATCH v5.1 4/8] xen: destroy_hvm_domain: Move reason into a variable, Ian Jackson, 2017/10/20
- Re: [Qemu-devel] [PATCH v5.1 4/8] xen: destroy_hvm_domain: Move reason into a variable, Stefano Stabellini, 2017/10/26
- [Qemu-devel] [PATCH v5.1 2/8] xen: restrict: use xentoolcore_restrict_all, Ian Jackson, 2017/10/20
- Re: [Qemu-devel] [PATCH v5.1 2/8] xen: restrict: use xentoolcore_restrict_all, Stefano Stabellini, 2017/10/26
- Re: [Qemu-devel] [PATCH v5.1 2/8] xen: restrict: use xentoolcore_restrict_all, Ian Jackson, 2017/10/27
- [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility, Ian Jackson, 2017/10/20
- Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility,
Anthony PERARD <=
- Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility, Ian Jackson, 2017/10/24
- Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility, Stefano Stabellini, 2017/10/26
- Re: [Qemu-devel] [PATCH v5.1 7/8] os-posix: Provide new -runas <uid>:<gid> facility, Ian Jackson, 2017/10/27
- [Qemu-devel] [PATCH v5.1 5/8] xen: move xc_interface compatibility fallback further up the file, Ian Jackson, 2017/10/20
- Re: [Qemu-devel] [PATCH v5.1 5/8] xen: move xc_interface compatibility fallback further up the file, Stefano Stabellini, 2017/10/26
- Re: [Qemu-devel] [PATCH v5.1 1/8] xen: link against xentoolcore, Stefano Stabellini, 2017/10/26
- Re: [Qemu-devel] [PATCH v5.1 1/8] xen: link against xentoolcore, Ian Jackson, 2017/10/27
Re: [Qemu-devel] [PATCH v5 0/8] xen: xen-domid-restrict improvements, no-reply, 2017/10/21