mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
rpc_server: Make errno return of get_logged_on_userlist explicit
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
aa147153c1
commit
76c1b77e79
@ -65,7 +65,7 @@ static int usr_info_cmp(const struct usrinfo *usr1, const struct usrinfo *usr2)
|
||||
Get a list of the names of all users logged into this machine
|
||||
********************************************************************/
|
||||
|
||||
static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
|
||||
static int get_logged_on_userlist(TALLOC_CTX *mem_ctx, char ***pusers)
|
||||
{
|
||||
char **users;
|
||||
int i, num_users = 0;
|
||||
@ -94,7 +94,7 @@ static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
|
||||
if (tmp == NULL) {
|
||||
TALLOC_FREE(tmp);
|
||||
endutxent();
|
||||
return NULL;
|
||||
return ENOMEM;
|
||||
}
|
||||
usr_infos = tmp;
|
||||
usr_infos[num_users].name = talloc_strdup(usr_infos,
|
||||
@ -102,7 +102,7 @@ static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
|
||||
if (usr_infos[num_users].name == NULL) {
|
||||
TALLOC_FREE(usr_infos);
|
||||
endutxent();
|
||||
return NULL;
|
||||
return ENOMEM;
|
||||
}
|
||||
usr_infos[num_users].login_time.tv_sec = u->ut_tv.tv_sec;
|
||||
usr_infos[num_users].login_time.tv_usec = u->ut_tv.tv_usec;
|
||||
@ -120,15 +120,16 @@ static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
|
||||
}
|
||||
TALLOC_FREE(usr_infos);
|
||||
endutxent();
|
||||
errno = 0;
|
||||
return users;
|
||||
*pusers = users;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
|
||||
static int get_logged_on_userlist(TALLOC_CTX *mem_ctx, char ***pusers)
|
||||
{
|
||||
return NULL;
|
||||
*pusers = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -316,6 +317,7 @@ static struct wkssvc_NetWkstaInfo102 *create_wks_info_102(TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct wkssvc_NetWkstaInfo102 *info102;
|
||||
char **users;
|
||||
int ret;
|
||||
|
||||
info102 = talloc(mem_ctx, struct wkssvc_NetWkstaInfo102);
|
||||
if (info102 == NULL) {
|
||||
@ -332,7 +334,12 @@ static struct wkssvc_NetWkstaInfo102 *create_wks_info_102(TALLOC_CTX *mem_ctx)
|
||||
info102, "%s", lp_workgroup());
|
||||
info102->lan_root = "";
|
||||
|
||||
users = get_logged_on_userlist(talloc_tos());
|
||||
ret = get_logged_on_userlist(talloc_tos(), &users);
|
||||
if (ret != 0) {
|
||||
TALLOC_FREE(info102);
|
||||
errno = ret;
|
||||
return NULL;
|
||||
}
|
||||
info102->logged_on_users = talloc_array_length(users);
|
||||
|
||||
TALLOC_FREE(users);
|
||||
@ -428,18 +435,20 @@ static struct wkssvc_NetWkstaEnumUsersCtr0 *create_enum_users0(
|
||||
{
|
||||
struct wkssvc_NetWkstaEnumUsersCtr0 *ctr0;
|
||||
char **users;
|
||||
int i, num_users;
|
||||
int i, num_users, ret;
|
||||
|
||||
ctr0 = talloc(mem_ctx, struct wkssvc_NetWkstaEnumUsersCtr0);
|
||||
if (ctr0 == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
users = get_logged_on_userlist(talloc_tos());
|
||||
if (users == NULL && errno != 0) {
|
||||
DEBUG(1,("get_logged_on_userlist error %d: %s\n",
|
||||
errno, strerror(errno)));
|
||||
ret = get_logged_on_userlist(talloc_tos(), &users);
|
||||
if (ret != 0) {
|
||||
DBG_WARNING("get_logged_on_userlist error %d: %s\n",
|
||||
ret,
|
||||
strerror(ret));
|
||||
TALLOC_FREE(ctr0);
|
||||
errno = ret;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -478,18 +487,20 @@ static struct wkssvc_NetWkstaEnumUsersCtr1 *create_enum_users1(
|
||||
struct dom_usr *dom_users;
|
||||
const char *pwd_server;
|
||||
char *pwd_tmp;
|
||||
int i, j, num_users, num_dom_users;
|
||||
int i, j, num_users, num_dom_users, ret;
|
||||
|
||||
ctr1 = talloc(mem_ctx, struct wkssvc_NetWkstaEnumUsersCtr1);
|
||||
if (ctr1 == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
users = get_logged_on_userlist(talloc_tos());
|
||||
if (users == NULL && errno != 0) {
|
||||
DEBUG(1,("get_logged_on_userlist error %d: %s\n",
|
||||
errno, strerror(errno)));
|
||||
ret = get_logged_on_userlist(talloc_tos(), &users);
|
||||
if (ret != 0) {
|
||||
DBG_WARNING("get_logged_on_userlist error %d: %s\n",
|
||||
ret,
|
||||
strerror(ret));
|
||||
TALLOC_FREE(ctr1);
|
||||
errno = ret;
|
||||
return NULL;
|
||||
}
|
||||
num_users = talloc_array_length(users);
|
||||
|
Loading…
x
Reference in New Issue
Block a user