summaryrefslogtreecommitdiffstats
path: root/login-utils/su-common.c
diff options
context:
space:
mode:
authorKarel Zak2016-10-13 13:14:58 +0200
committerKarel Zak2017-09-18 11:48:56 +0200
commitb1195aa07d9f712e87cd7eda8a392e63ce7b01c2 (patch)
treede8724b6dc2a5a5e76752acafb1ef3ac155c935d /login-utils/su-common.c
parentsu: fix indention (diff)
downloadkernel-qcow2-util-linux-b1195aa07d9f712e87cd7eda8a392e63ce7b01c2.tar.gz
kernel-qcow2-util-linux-b1195aa07d9f712e87cd7eda8a392e63ce7b01c2.tar.xz
kernel-qcow2-util-linux-b1195aa07d9f712e87cd7eda8a392e63ce7b01c2.zip
su: cosmetic changes after indent
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/su-common.c')
-rw-r--r--login-utils/su-common.c84
1 files changed, 34 insertions, 50 deletions
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index bfcd49405..98774051c 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -1,48 +1,26 @@
-/* su for Linux. Run a shell with substitute user and group IDs.
- Copyright (C) 1992-2006 Free Software Foundation, Inc.
- Copyright (C) 2012 SUSE Linux Products GmbH, Nuernberg
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-/* Run a shell with the real and effective UID and GID and groups
- of USER, default `root'.
-
- The shell run is taken from USER's password entry, /bin/sh if
- none is specified there. If the account has a password, su
- prompts for a password unless run by a user with real UID 0.
-
- Does not change the current directory.
- Sets `HOME' and `SHELL' from the password entry for USER, and if
- USER is not root, sets `USER' and `LOGNAME' to USER.
- The subshell is not a login shell.
-
- If one or more ARGs are given, they are passed as additional
- arguments to the subshell.
-
- Does not handle /bin/sh or other shells specially
- (setting argv[0] to "-su", passing -c only to certain shells, etc.).
- I don't see the point in doing that, and it's ugly.
-
- Based on an implementation by David MacKenzie <djm@gnu.ai.mit.edu>. */
-
-enum {
- EXIT_CANNOT_INVOKE = 126,
- EXIT_ENOENT = 127
-};
-
-#include <config.h>
+/*
+ * su(1) for Linux. Run a shell with substitute user and group IDs.
+ *
+ * Copyright (C) 1992-2006 Free Software Foundation, Inc.
+ * Copyright (C) 2012 SUSE Linux Products GmbH, Nuernberg
+ * Copyright (C) 2016 Karel Zak <kzak@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details. You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ *
+ *
+ * Based on an implementation by David MacKenzie <djm@gnu.ai.mit.edu>.
+ */
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
@@ -50,9 +28,9 @@ enum {
#include <grp.h>
#include <security/pam_appl.h>
#ifdef HAVE_SECURITY_PAM_MISC_H
-#include <security/pam_misc.h>
+# include <security/pam_misc.h>
#elif defined(HAVE_SECURITY_OPENPAM_H)
-#include <security/openpam.h>
+# include <security/openpam.h>
#endif
#include <signal.h>
#include <sys/wait.h>
@@ -62,6 +40,7 @@ enum {
#include "err.h"
#include <stdbool.h>
+
#include "c.h"
#include "xalloc.h"
#include "nls.h"
@@ -71,6 +50,9 @@ enum {
#include "strutils.h"
#include "ttyutils.h"
+#include "logindefs.h"
+#include "su-common.h"
+
/* name of the pam configuration files. separate configs for su and su - */
#define PAM_SRVNAME_SU "su"
#define PAM_SRVNAME_SU_L "su-l"
@@ -83,9 +65,6 @@ enum {
#define is_pam_failure(_rc) ((_rc) != PAM_SUCCESS)
-#include "logindefs.h"
-#include "su-common.h"
-
/* The shell to run if none is given in the user's passwd entry. */
#define DEFAULT_SHELL "/bin/sh"
@@ -96,6 +75,11 @@ enum {
extern char **environ;
#endif
+enum {
+ EXIT_CANNOT_INVOKE = 126,
+ EXIT_ENOENT = 127
+};
+
static void run_shell(char const *, char const *, char **, size_t)
__attribute__ ((__noreturn__));