summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang zhengguang <zhengguang.zhang@intel.com>2014-12-04 05:25:42 (GMT)
committerZhang zhengguang <zhengguang.zhang@intel.com>2014-12-08 01:14:10 (GMT)
commit5986f2f3216534307208f5247969d1adb94065c5 (patch)
tree2f26ee7605c66baf89bd69c3426f66640e378527
parentdaeab548458c650615fa9f1c869e0575dd1ca2a1 (diff)
downloadconnman-5986f2f3216534307208f5247969d1adb94065c5.zip
connman-5986f2f3216534307208f5247969d1adb94065c5.tar.gz
connman-5986f2f3216534307208f5247969d1adb94065c5.tar.bz2
In curernt IVI image, systemd doesn't write utmp entries for logged in users, so that ConnMan can't get the related user info, under which condition, it doesn't need to forbid service auto connect for this user. Change-Id: I4ca33b2b43ac351d1be8c862808304d8a17d8d7d
-rw-r--r--src/service.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/service.c b/src/service.c
index 86dffaf..974a087 100644
--- a/src/service.c
+++ b/src/service.c
@@ -390,16 +390,16 @@ static GList *connman_service_get_login_users()
setutxent();
while ((utmp = getutxent()) != NULL) {
- if (utmp->ut_user != USER_ROOT && utmp->ut_type != USER_PROCESS)
- continue;
+ DBG("User Name: %s", utmp->ut_user);
pwd = getpwnam(utmp->ut_user);
-
- if (!g_list_find(user_list, GUINT_TO_POINTER(pwd->pw_uid)))
- user_list = g_list_append(user_list,
+ if (pwd) {
+ if (!g_list_find(user_list, GUINT_TO_POINTER(pwd->pw_uid)))
+ user_list = g_list_append(user_list,
GUINT_TO_POINTER(pwd->pw_uid));
- DBG("User Name: %s, UID: %d", utmp->ut_user, pwd->pw_uid);
+ DBG("User Name: %s, UID: %d", utmp->ut_user, pwd->pw_uid);
+ }
}
endutxent();
@@ -416,10 +416,14 @@ static bool is_service_owner_user_login(struct connman_service *service)
if (service->type != CONNMAN_SERVICE_TYPE_WIFI)
return true;
- user_list = connman_service_get_login_users();
-
DBG("service favorite user id is: %d", service->user.favorite_user);
+ user_list = connman_service_get_login_users();
+ if (user_list == NULL) {
+ DBG("Can not get any logged in user info.");
+ return true;
+ }
+
for (list = user_list; list; list = list->next) {
uid_t uid = GPOINTER_TO_UINT(list->data);