123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- $OpenBSD: patch-src_daemon_c,v 1.32 2016/06/10 15:17:36 ajacoutot Exp $
- --- src/daemon.c.orig Wed Feb 25 14:51:44 2015
- +++ src/daemon.c Fri Jun 10 16:43:03 2016
- @@ -33,6 +33,10 @@
- #include <errno.h>
- #include <sys/types.h>
-
- +#ifdef __OpenBSD__
- +#include <grp.h> /* getgrnam */
- +#endif
- +
- #include <glib.h>
- #include <glib/gi18n.h>
- #include <glib-object.h>
- @@ -46,7 +50,11 @@
- #include "util.h"
-
- #define PATH_PASSWD "/etc/passwd"
- +#if defined (HAVE_SHADOW_H)
- #define PATH_SHADOW "/etc/shadow"
- +#elif defined (__OpenBSD__)
- +#define PATH_SHADOW "/etc/master.passwd"
- +#endif
- #define PATH_GROUP "/etc/group"
- #define PATH_GDM_CUSTOM "/etc/gdm/custom.conf"
-
- @@ -877,7 +885,11 @@ daemon_create_user_authorized_cb (Daemon
- CreateUserData *cd = data;
- User *user;
- GError *error;
- +#ifndef __OpenBSD__
- const gchar *argv[9];
- +#else
- + const gchar *argv[11];
- +#endif
-
- if (getpwnam (cd->user_name) != NULL) {
- throw_error (context, ERROR_USER_EXISTS, "A user with name '%s' already exists", cd->user_name);
- @@ -894,9 +906,17 @@ daemon_create_user_authorized_cb (Daemon
- if (cd->account_type == ACCOUNT_TYPE_ADMINISTRATOR) {
- argv[4] = "-G";
- argv[5] = ADMIN_GROUP;
- +#ifdef __OpenBSD__
- + argv[6] = "-L";
- + argv[7] = "staff";
- + argv[8] = "--";
- + argv[9] = cd->user_name;
- + argv[10] = NULL;
- +#else
- argv[6] = "--";
- argv[7] = cd->user_name;
- argv[8] = NULL;
- +#endif
- }
- else if (cd->account_type == ACCOUNT_TYPE_STANDARD) {
- argv[4] = "--";
- @@ -1083,6 +1103,34 @@ daemon_delete_user_authorized_cb (Daemon
- return;
- }
-
- +/*
- + * Under OpenBSD there is no /etc/login.defs (for USERGROUPS_ENAB), so
- + * we need to explicitely remove the user's group if it contains no more
- + * members and matches the username.
- + */
- +#ifdef __OpenBSD__
- + struct group *grp;
- + GError *grperror;
- + const gchar *grpargv[3];
- +
- + grp = getgrnam (pwent->pw_name);
- +
- + if ((grp != NULL) && (*grp->gr_name == *pwent->pw_name) && (*grp->gr_mem == NULL)) {
- + sys_log (context, "delete group '%d'", pwent->pw_gid);
- +
- + grpargv[0] = "/usr/sbin/groupdel";
- + grpargv[1] = pwent->pw_name;
- + grpargv[2] = NULL;
- +
- + grperror = NULL;
- + if (!spawn_with_login_uid (context, grpargv, &grperror)) {
- + throw_error (context, ERROR_FAILED, "running '%s' failed: %s", grpargv[0], grperror->message);
- + g_error_free (grperror);
- + return;
- + }
- + }
- +#endif
- +
- sys_log (context, "delete user '%s' (%d)", pwent->pw_name, ud->uid);
-
- if (daemon->priv->autologin != NULL) {
- @@ -1108,11 +1156,18 @@ daemon_delete_user_authorized_cb (Daemon
-
- argv[0] = "/usr/sbin/userdel";
- if (ud->remove_files) {
- +#ifdef __OpenBSD__
- + argv[1] = "-r";
- + argv[2] = "--";
- + argv[3] = pwent->pw_name;
- + argv[4] = NULL;
- +#else
- argv[1] = "-f";
- argv[2] = "-r";
- argv[3] = "--";
- argv[4] = pwent->pw_name;
- argv[5] = NULL;
- +#endif
- }
- else {
- argv[1] = "-f";
|