on bionic help sign in
43 lines 1.2 kB history raw
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
18#include <glib.h>
19#include <grp.h>
20#include <stdlib.h>
22const gchar *g_get_user_name(void)
24 // The normal glib version parses pwent entries
25 return g_getenv("TEST_USER");
28struct group *getgrnam(const char *group_name)
30 static struct group rv = {NULL, NULL, 0, NULL};
32 g_free(rv.gr_name);
33 g_strfreev(rv.gr_mem);
35 rv.gr_name = g_strdup(group_name);
36 rv.gr_passwd = NULL;
37 rv.gr_gid = 9999;
38 rv.gr_mem = NULL;
39 if (g_strcmp0(group_name, "nopasswdlogin") == 0) {
40 rv.gr_mem = g_strsplit(g_getenv("TEST_NOPASSWD_USERS"), ",", 0);
41 }
42 return &rv;