Skip to content
Snippets Groups Projects
Commit d2803376 authored by Philippe Mathieu-Daudé's avatar Philippe Mathieu-Daudé Committed by Markus Armbruster
Browse files

os-posix: Clean up global variable shadowing


Fix:

  os-posix.c:103:31: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  bool os_set_runas(const char *optarg)
                                ^
  os-posix.c:176:32: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  void os_set_chroot(const char *optarg)
                                 ^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
  extern char *optarg;                    /* getopt(3) external variables */
               ^

Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231004120019.93101-5-philmd@linaro.org>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent 73071f19
No related branches found
No related tags found
No related merge requests found
......@@ -49,8 +49,8 @@ void os_setup_signal_handling(void);
int os_set_daemonize(bool d);
bool is_daemonized(void);
void os_daemonize(void);
bool os_set_runas(const char *optarg);
void os_set_chroot(const char *optarg);
bool os_set_runas(const char *user_id);
void os_set_chroot(const char *path);
void os_setup_post(void);
int os_mlock(void);
......
......@@ -94,13 +94,13 @@ static uid_t user_uid = (uid_t)-1; /* -1 -1 >=0 */
static gid_t user_gid = (gid_t)-1; /* -1 -1 >=0 */
/*
* Prepare to change user ID. optarg can be one of 3 forms:
* Prepare to change user ID. user_id can be one of 3 forms:
* - a username, in which case user ID will be changed to its uid,
* with primary and supplementary groups set up too;
* - a numeric uid, in which case only the uid will be set;
* - a pair of numeric uid:gid.
*/
bool os_set_runas(const char *optarg)
bool os_set_runas(const char *user_id)
{
unsigned long lv;
const char *ep;
......@@ -108,14 +108,14 @@ bool os_set_runas(const char *optarg)
gid_t got_gid;
int rc;
user_pwd = getpwnam(optarg);
user_pwd = getpwnam(user_id);
if (user_pwd) {
user_uid = -1;
user_gid = -1;
return true;
}
rc = qemu_strtoul(optarg, &ep, 0, &lv);
rc = qemu_strtoul(user_id, &ep, 0, &lv);
got_uid = lv; /* overflow here is ID in C99 */
if (rc || *ep != ':' || got_uid != lv || got_uid == (uid_t)-1) {
return false;
......@@ -173,9 +173,9 @@ static void change_process_uid(void)
static const char *chroot_dir;
void os_set_chroot(const char *optarg)
void os_set_chroot(const char *path)
{
chroot_dir = optarg;
chroot_dir = path;
}
static void change_root(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment