mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
libxl: libxl__dm_runas_helper: return pwd
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com>
This commit is contained in:
1 parent
bfc8f25556
commit
89da286192
1 file changed
+7
-4
@@ -750,7 +750,8 @@ libxl__detect_gfx_passthru_kind(libxl__gc *gc,
|
||||
}
|
||||
|
||||
/* return 1 if the user was found, 0 if it was not, -1 on error */
|
||||
static int libxl__dm_runas_helper(libxl__gc *gc, const char *username)
|
||||
static int libxl__dm_runas_helper(libxl__gc *gc, const char *username,
|
||||
struct passwd **pwd_r)
|
||||
{
|
||||
struct passwd pwd, *user = NULL;
|
||||
char *buf = NULL;
|
||||
@@ -774,8 +775,10 @@ static int libxl__dm_runas_helper(libxl__gc *gc, const char *username)
|
||||
}
|
||||
if (ret != 0)
|
||||
return ERROR_FAIL;
|
||||
if (user != NULL)
|
||||
if (user != NULL) {
|
||||
if (pwd_r) *pwd_r = pwd;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1642,14 +1645,14 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
|
||||
}
|
||||
|
||||
user = GCSPRINTF("%s%d", LIBXL_QEMU_USER_BASE, guest_domid);
|
||||
ret = libxl__dm_runas_helper(gc, user);
|
||||
ret = libxl__dm_runas_helper(gc, user, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret > 0)
|
||||
goto end_search;
|
||||
|
||||
user = LIBXL_QEMU_USER_SHARED;
|
||||
ret = libxl__dm_runas_helper(gc, user);
|
||||
ret = libxl__dm_runas_helper(gc, user, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret > 0) {
|
||||
|
||||