~ubuntu-branches/ubuntu/natty/sysvinit/natty-updates

« back to all changes in this revision

Viewing changes to src/sulogin.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2009-09-07 19:56:53 UTC
  • mfrom: (1.1.4 upstream) (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090907195653-2i6t0j91wfbf1f0d
Tags: 2.87dsf-4ubuntu1
* Merge from debian unstable, remaining changes:
  - Support Cell processor:
    + debian/initscripts/postinst: Create spu system group and /spu mount
      point if we are running on a Cell processor.
    + debian/initscripts/etc/init.d/mountkernfs.sh: Mount spufs if Cell
      processor is detected.
    + debian/initscripts/lib/init/mount-functions.sh: Modprobe spufs
      if not available.
    + debian/control: Add initscripts dependency 'passwd' for groupadd.
    (Forwarded to Debian #483399)
  - Use tmpfs mounts for /var/lock and /var/run:
    + debian/initscripts/share/default.rcS: Enable RAMRUN and RAMLOCK by
      default.
    + debian/initscripts.postinst: Enable RAMRUN and RAMLOCK in
      /etc/default/rcS on upgrades. This needs to be kept until the next
      LTS.
    + debian/initscripts/etc/init.d/mountkernfs.sh: Propagate files from the
      initramfs to our new /var/run, so that we can populate
      /var/run/sendsigs.omit from initramfs.
  - Boot ordering differences:
    + mountkernfs.sh: 02 -> 01
    + mountdevsubfs.sh: 04 -> 11
    + bootlogd: disabled by default
    + checkroot.sh: 10 -> 20
    + mtab.sh: 12 -> 22
  - debian/patches/91_sulogin_lockedpw.dpatch: Disable "root account is
    locked" warning, since this is the default in Ubuntu. Document this in
    sulogin.8.
  - debian/control: Drop Essential: yes from packages since we use Upstart.
  - debian/control: Conflict/Replace sysvconfig which has also previously
    provided service(8).
  - debian/control, debian/rules: Previous name for sysvinit-utils was
    'sysvutils' in Ubuntu, so Conflict/Replace/Provide it. Also create a
    dummy sysvutils package, since Hardy has reverse versioned dependencies
    to it. This needs to be kept until after the next LTS.
  - debian/control: Depend on lsb-base (>= 3.2-14) for status_of_proc()
    function.
  - debian/initscripts/etc/init.d/checkfs.sh: Don't depend on hwclockfirst
    which Ubuntu does not have.
  - debian/initscripts/etc/init.d/mountkernfs.sh: Always mount devpts, and
    do not touch /dev/ptmx (which is already managed by udev).
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount fusectl if it is
    available
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount securityfs if it is
    available. This allows for easier AppArmor confinement of applications
    early in the boot process. LP: #399954
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount debugfs if it is
    available.
  - debian/initscripts/etc/init.d/ondemand: Sleep for 60 seconds, then
    set CPU Frequency Scaling governor to "ondemand".   LP: #341573.
  - debian/initscripts/etc/init.d/umountfs: Don't unmount filesystems
    that precede root or use force for some mountpoints.
  - debian/initscripts/etc/network/if-up.d/mountnfs: Rename ifstate
    file to /var/run/network/ifstate
  - ./debian/initscripts/lib/init/usplash-fsck-functions.sh: Use blkid,
    vol_id is gone.
  - debian/initscripts.{pre,postinst}: waitnfs.sh -> mountnfs.sh renaming
    transition. This needs to be kept until after the next LTS.

LP: #32455, #94120, #160197, #382097 (amongst others).

* debian/sysv-rc/sbin/update-rc.d: Dropped support for "multiuser"
  command-line option.
* debian/rules: Compat symlink from /usr/bin/service to /usr/sbin/service
* debian/initscripts.postinst: Transition from bootlogs.sh to bootlogs

* debian/sysv-rc.postinst: Don't try and use insserv by default, though
  everything's in place for you to try if you like.  It can be activated
  with:
      USEINSSERV=yes dpkg-reconfigure sysv-rc

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <pwd.h>
24
24
#include <shadow.h>
25
25
#include <termios.h>
 
26
#include <errno.h>
26
27
#include <sys/ioctl.h>
27
28
#if defined(__GLIBC__)
28
29
#  include <crypt.h>
29
30
#endif
30
31
 
 
32
#ifdef WITH_SELINUX
 
33
#  include <selinux/selinux.h>
 
34
#  include <selinux/get_context_list.h>
 
35
#endif
 
36
 
31
37
#define CHECK_DES       1
32
38
#define CHECK_MD5       1
33
39
 
34
40
#define F_PASSWD        "/etc/passwd"
35
41
#define F_SHADOW        "/etc/shadow"
36
42
#define BINSH           "/bin/sh"
 
43
#define STATICSH        "/bin/sash"
37
44
 
38
45
char *Version = "@(#)sulogin 2.85-3 23-Apr-2003 miquels@cistron.nl";
39
46
 
335
342
        signal(SIGINT, SIG_DFL);
336
343
        signal(SIGTSTP, SIG_DFL);
337
344
        signal(SIGQUIT, SIG_DFL);
 
345
#ifdef WITH_SELINUX
 
346
        if (is_selinux_enabled > 0) {
 
347
          security_context_t scon=NULL;
 
348
          char *seuser=NULL;
 
349
          char *level=NULL;
 
350
          if (getseuserbyname("root", &seuser, &level) == 0)
 
351
                  if (get_default_context_with_level(seuser, level, 0, &scon) > 0) {
 
352
                          if (setexeccon(scon) != 0) 
 
353
                                  fprintf(stderr, "setexeccon faile\n");
 
354
                          freecon(scon);
 
355
                  }
 
356
                free(seuser);
 
357
                free(level);
 
358
        }
 
359
#endif
338
360
        execl(sushell, shell, NULL);
339
361
        perror(sushell);
340
362
 
341
363
        setenv("SHELL", BINSH, 1);
342
364
        execl(BINSH, profile ? "-sh" : "sh", NULL);
343
365
        perror(BINSH);
 
366
 
 
367
        /* Fall back to staticly linked shell if both the users shell
 
368
           and /bin/sh failed to execute. */
 
369
        setenv("SHELL", STATICSH, 1);
 
370
        execl(STATICSH, STATICSH, NULL);
 
371
        perror(STATICSH);
344
372
}
345
373
 
346
374
void usage(void)
427
455
                        } else
428
456
                                close(fd);
429
457
                }
 
458
        } else if (getpid() == 1) {
 
459
                /* We are init. We hence need to set a session anyway */
 
460
                setsid();
 
461
                if (ioctl(0, TIOCSCTTY, (char *)1))
 
462
                        perror("ioctl(TIOCSCTTY)");
430
463
        }
431
464
 
432
465
        /*