Ignore:
Timestamp:
Nov 6, 2007, 11:01:53 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod? silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian? keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René? Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi-busybox/miscutils/crontab.c

    r821 r1770  
    1111 */
    1212
    13 #include "busybox.h"
    14 #include <stdio.h>
    15 #include <stdlib.h>
    16 #include <stdarg.h>
    17 #include <string.h>
    18 #include <errno.h>
    19 #include <time.h>
    20 #include <dirent.h>
    21 #include <fcntl.h>
    22 #include <unistd.h>
    23 #include <syslog.h>
    24 #include <signal.h>
    25 #include <getopt.h>
    26 #include <sys/ioctl.h>
    27 #include <sys/wait.h>
    28 #include <sys/stat.h>
    29 #include <sys/resource.h>
     13#include "libbb.h"
    3014
    3115#ifndef CRONTABS
     
    3923#endif
    4024#ifndef PATH_VI
    41 #define PATH_VI         "/bin/vi"   /* location of vi       */
     25#define PATH_VI         "/bin/vi"   /* location of vi */
    4226#endif
    4327
    44 static const char  *CDir = CRONTABS;
     28static const char *CDir = CRONTABS;
    4529
    4630static void EditFile(const char *user, const char *file);
    4731static int GetReplaceStream(const char *user, const char *file);
    48 static int  ChangeUser(const char *user, short dochdir);
    49 
    50 int
    51 crontab_main(int ac, char **av)
     32static int ChangeUser(const char *user, short dochdir);
     33
     34int crontab_main(int ac, char **av);
     35int crontab_main(int ac, char **av)
    5236{
    53     enum { NONE, EDIT, LIST, REPLACE, DELETE } option = NONE;
    54     const struct passwd *pas;
    55     const char *repFile = NULL;
    56     int repFd = 0;
    57     int i;
    58     char caller[256];           /* user that ran program */
    59     int   UserId;
    60 
    61     UserId = getuid();
    62     if ((pas = getpwuid(UserId)) == NULL)
    63     bb_perror_msg_and_die("getpwuid");
    64 
    65     safe_strncpy(caller, pas->pw_name, sizeof(caller));
    66 
    67     i = 1;
    68     if (ac > 1) {
    69     if (av[1][0] == '-' && av[1][1] == 0) {
    70         option = REPLACE;
    71         ++i;
    72     } else if (av[1][0] != '-') {
    73         option = REPLACE;
    74         ++i;
    75         repFile = av[1];
    76     }
    77     }
    78 
    79     for (; i < ac; ++i) {
    80     char *ptr = av[i];
    81 
    82     if (*ptr != '-')
    83         break;
    84     ptr += 2;
    85 
    86     switch(ptr[-1]) {
    87     case 'l':
    88         if (ptr[-1] == 'l')
    89         option = LIST;
    90         /* fall through */
    91     case 'e':
    92         if (ptr[-1] == 'e')
    93         option = EDIT;
    94         /* fall through */
    95     case 'd':
    96         if (ptr[-1] == 'd')
    97         option = DELETE;
    98         /* fall through */
    99     case 'u':
    100         if (i + 1 < ac && av[i+1][0] != '-') {
    101         ++i;
    102         if (getuid() == geteuid()) {
    103             pas = getpwnam(av[i]);
    104             if (pas) {
    105             UserId = pas->pw_uid;
    106             } else {
    107             bb_error_msg_and_die("user %s unknown", av[i]);
    108             }
    109         } else {
    110             bb_error_msg_and_die("only the superuser may specify a user");
    111         }
    112         }
    113         break;
    114     case 'c':
    115         if (getuid() == geteuid()) {
    116         CDir = (*ptr) ? ptr : av[++i];
    117         } else {
    118         bb_error_msg_and_die("-c option: superuser only");
    119         }
    120         break;
     37    enum { NONE, EDIT, LIST, REPLACE, DELETE } option = NONE;
     38    const struct passwd *pas;
     39    const char *repFile = NULL;
     40    int repFd = 0;
     41    int i;
     42    char caller[256];           /* user that ran program */
     43    char buf[1024];
     44    int UserId;
     45
     46    UserId = getuid();
     47    pas = getpwuid(UserId);
     48    if (pas == NULL)
     49        bb_perror_msg_and_die("getpwuid");
     50
     51    safe_strncpy(caller, pas->pw_name, sizeof(caller));
     52
     53    i = 1;
     54    if (ac > 1) {
     55        if (LONE_DASH(av[1])) {
     56            option = REPLACE;
     57            ++i;
     58        } else if (av[1][0] != '-') {
     59            option = REPLACE;
     60            ++i;
     61            repFile = av[1];
     62        }
     63    }
     64
     65    for (; i < ac; ++i) {
     66        char *ptr = av[i];
     67
     68        if (*ptr != '-')
     69            break;
     70        ptr += 2;
     71
     72        switch (ptr[-1]) {
     73        case 'l':
     74            if (ptr[-1] == 'l')
     75                option = LIST;
     76            /* fall through */
     77        case 'e':
     78            if (ptr[-1] == 'e')
     79                option = EDIT;
     80            /* fall through */
     81        case 'd':
     82            if (ptr[-1] == 'd')
     83                option = DELETE;
     84            /* fall through */
     85        case 'u':
     86            if (i + 1 < ac && av[i+1][0] != '-') {
     87                ++i;
     88                if (getuid() == geteuid()) {
     89                    pas = getpwnam(av[i]);
     90                    if (pas) {
     91                        UserId = pas->pw_uid;
     92                    } else {
     93                        bb_error_msg_and_die("user %s unknown", av[i]);
     94                    }
     95                } else {
     96                    bb_error_msg_and_die("only the superuser may specify a user");
     97                }
     98            }
     99            break;
     100        case 'c':
     101            if (getuid() == geteuid()) {
     102                CDir = (*ptr) ? ptr : av[++i];
     103            } else {
     104                bb_error_msg_and_die("-c option: superuser only");
     105            }
     106            break;
     107        default:
     108            i = ac;
     109            break;
     110        }
     111    }
     112    if (i != ac || option == NONE)
     113        bb_show_usage();
     114
     115    /*
     116     * Get password entry
     117     */
     118
     119    pas = getpwuid(UserId);
     120    if (pas == NULL)
     121        bb_perror_msg_and_die("getpwuid");
     122
     123    /*
     124     * If there is a replacement file, obtain a secure descriptor to it.
     125     */
     126
     127    if (repFile) {
     128        repFd = GetReplaceStream(caller, repFile);
     129        if (repFd < 0)
     130            bb_error_msg_and_die("cannot read replacement file");
     131    }
     132
     133    /*
     134     * Change directory to our crontab directory
     135     */
     136
     137    xchdir(CDir);
     138
     139    /*
     140     * Handle options as appropriate
     141     */
     142
     143    switch (option) {
     144    case LIST:
     145        {
     146            FILE *fi;
     147
     148            fi = fopen(pas->pw_name, "r");
     149            if (fi) {
     150                while (fgets(buf, sizeof(buf), fi) != NULL)
     151                    fputs(buf, stdout);
     152                fclose(fi);
     153            } else {
     154                bb_error_msg("no crontab for %s", pas->pw_name);
     155            }
     156        }
     157        break;
     158    case EDIT:
     159        {
     160/* FIXME: messy code here! we have file copying helpers for this! */
     161            FILE *fi;
     162            int fd;
     163            int n;
     164            char tmp[128];
     165
     166            snprintf(tmp, sizeof(tmp), TMPDIR "/crontab.%d", getpid());
     167            fd = xopen3(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600);
     168/* race, use fchown */
     169            chown(tmp, getuid(), getgid());
     170            fi = fopen(pas->pw_name, "r");
     171            if (fi) {
     172                while ((n = fread(buf, 1, sizeof(buf), fi)) > 0)
     173                    full_write(fd, buf, n);
     174            }
     175            EditFile(caller, tmp);
     176            remove(tmp);
     177            lseek(fd, 0L, SEEK_SET);
     178            repFd = fd;
     179        }
     180        option = REPLACE;
     181        /* fall through */
     182    case REPLACE:
     183        {
     184/* same here */
     185            char path[1024];
     186            int fd;
     187            int n;
     188
     189            snprintf(path, sizeof(path), "%s.new", pas->pw_name);
     190            fd = open(path, O_CREAT|O_TRUNC|O_APPEND|O_WRONLY, 0600);
     191            if (fd >= 0) {
     192                while ((n = read(repFd, buf, sizeof(buf))) > 0) {
     193                    full_write(fd, buf, n);
     194                }
     195                close(fd);
     196                rename(path, pas->pw_name);
     197            } else {
     198                bb_error_msg("cannot create %s/%s", CDir, path);
     199            }
     200            close(repFd);
     201        }
     202        break;
     203    case DELETE:
     204        remove(pas->pw_name);
     205        break;
     206    case NONE:
    121207    default:
    122         i = ac;
    123         break;
    124     }
    125     }
    126     if (i != ac || option == NONE)
    127     bb_show_usage();
    128 
    129     /*
    130      * Get password entry
    131      */
    132 
    133     if ((pas = getpwuid(UserId)) == NULL)
    134     bb_perror_msg_and_die("getpwuid");
    135 
    136     /*
    137      * If there is a replacement file, obtain a secure descriptor to it.
    138      */
    139 
    140     if (repFile) {
    141     repFd = GetReplaceStream(caller, repFile);
    142     if (repFd < 0)
    143         bb_error_msg_and_die("unable to read replacement file");
    144     }
    145 
    146     /*
    147      * Change directory to our crontab directory
    148      */
    149 
    150     bb_xchdir(CDir);
    151 
    152     /*
    153      * Handle options as appropriate
    154      */
    155 
    156     switch(option) {
    157     case LIST:
    158     {
    159         FILE *fi;
    160         char buf[1024];
    161 
    162         if ((fi = fopen(pas->pw_name, "r"))) {
    163         while (fgets(buf, sizeof(buf), fi) != NULL)
    164             fputs(buf, stdout);
    165         fclose(fi);
    166         } else {
    167         bb_error_msg("no crontab for %s", pas->pw_name);
    168         }
    169     }
    170     break;
    171     case EDIT:
    172     {
    173         FILE *fi;
    174         int fd;
    175         int n;
    176         char tmp[128];
    177         char buf[1024];
    178 
    179         snprintf(tmp, sizeof(tmp), TMPDIR "/crontab.%d", getpid());
    180         fd = bb_xopen3(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600);
    181         chown(tmp, getuid(), getgid());
    182         if ((fi = fopen(pas->pw_name, "r"))) {
    183         while ((n = fread(buf, 1, sizeof(buf), fi)) > 0)
    184             write(fd, buf, n);
    185         }
    186         EditFile(caller, tmp);
    187         remove(tmp);
    188         lseek(fd, 0L, 0);
    189         repFd = fd;
    190     }
    191     option = REPLACE;
    192     /* fall through */
    193     case REPLACE:
    194     {
    195         char buf[1024];
    196         char path[1024];
    197         int fd;
    198         int n;
    199 
    200         snprintf(path, sizeof(path), "%s.new", pas->pw_name);
    201         if ((fd = open(path, O_CREAT|O_TRUNC|O_APPEND|O_WRONLY, 0600)) >= 0) {
    202         while ((n = read(repFd, buf, sizeof(buf))) > 0) {
    203             write(fd, buf, n);
    204         }
    205         close(fd);
    206         rename(path, pas->pw_name);
    207         } else {
    208         bb_error_msg("unable to create %s/%s", CDir, path);
    209         }
    210         close(repFd);
    211     }
    212     break;
    213     case DELETE:
    214     remove(pas->pw_name);
    215     break;
    216     case NONE:
    217     default:
    218     break;
    219     }
    220 
    221     /*
    222      *  Bump notification file.  Handle window where crond picks file up
    223      *  before we can write our entry out.
    224      */
    225 
    226     if (option == REPLACE || option == DELETE) {
    227     FILE *fo;
    228     struct stat st;
    229 
    230     while ((fo = fopen(CRONUPDATE, "a"))) {
    231         fprintf(fo, "%s\n", pas->pw_name);
    232         fflush(fo);
    233         if (fstat(fileno(fo), &st) != 0 || st.st_nlink != 0) {
    234         fclose(fo);
    235208        break;
    236         }
    237         fclose(fo);
    238         /* loop */
    239     }
    240     if (fo == NULL) {
    241         bb_error_msg("unable to append to %s/%s", CDir, CRONUPDATE);
    242     }
    243     }
    244     return 0;
     209    }
     210
     211    /*
     212     *  Bump notification file.  Handle window where crond picks file up
     213     *  before we can write our entry out.
     214     */
     215
     216    if (option == REPLACE || option == DELETE) {
     217        FILE *fo;
     218        struct stat st;
     219
     220        while ((fo = fopen(CRONUPDATE, "a"))) {
     221            fprintf(fo, "%s\n", pas->pw_name);
     222            fflush(fo);
     223            if (fstat(fileno(fo), &st) != 0 || st.st_nlink != 0) {
     224                fclose(fo);
     225                break;
     226            }
     227            fclose(fo);
     228            /* loop */
     229        }
     230        if (fo == NULL) {
     231            bb_error_msg("cannot append to %s/%s", CDir, CRONUPDATE);
     232        }
     233    }
     234    return 0;
    245235}
    246236
    247 static int
    248 GetReplaceStream(const char *user, const char *file)
     237static int GetReplaceStream(const char *user, const char *file)
    249238{
    250     int filedes[2];
    251     int pid;
    252     int fd;
    253     int n;
    254     char buf[1024];
    255 
    256     if (pipe(filedes) < 0) {
    257     perror("pipe");
    258     return(-1);
    259     }
    260     if ((pid = fork()) < 0) {
    261     perror("fork");
    262     return(-1);
    263     }
    264     if (pid > 0) {
    265     /*
    266      * PARENT
    267      */
    268 
    269     close(filedes[1]);
    270     if (read(filedes[0], buf, 1) != 1) {
    271         close(filedes[0]);
    272         filedes[0] = -1;
    273     }
    274     return(filedes[0]);
    275     }
    276 
    277     /*
    278      * CHILD
    279      */
    280 
    281     close(filedes[0]);
    282 
    283     if (ChangeUser(user, 0) < 0)
     239    int filedes[2];
     240    int pid;
     241    int fd;
     242    int n;
     243    char buf[1024];
     244
     245    if (pipe(filedes) < 0) {
     246        perror("pipe");
     247        return -1;
     248    }
     249    pid = fork();
     250    if (pid < 0) {
     251        perror("fork");
     252        return -1;
     253    }
     254    if (pid > 0) {
     255        /*
     256         * PARENT
     257         */
     258
     259        close(filedes[1]);
     260        if (read(filedes[0], buf, 1) != 1) {
     261            close(filedes[0]);
     262            filedes[0] = -1;
     263        }
     264        return filedes[0];
     265    }
     266
     267    /*
     268     * CHILD
     269     */
     270
     271    close(filedes[0]);
     272
     273    if (ChangeUser(user, 0) < 0)
     274        exit(0);
     275
     276    xfunc_error_retval = 0;
     277    fd = xopen(file, O_RDONLY);
     278    buf[0] = 0;
     279    write(filedes[1], buf, 1);
     280    while ((n = read(fd, buf, sizeof(buf))) > 0) {
     281        write(filedes[1], buf, n);
     282    }
    284283    exit(0);
    285 
    286     bb_default_error_retval = 0;
    287     fd = bb_xopen3(file, O_RDONLY, 0);
    288     buf[0] = 0;
    289     write(filedes[1], buf, 1);
    290     while ((n = read(fd, buf, sizeof(buf))) > 0) {
    291     write(filedes[1], buf, n);
    292     }
    293     exit(0);
    294284}
    295285
    296 static void
    297 EditFile(const char *user, const char *file)
     286static void EditFile(const char *user, const char *file)
    298287{
    299     int pid;
    300 
    301     if ((pid = fork()) == 0) {
    302     /*
    303      * CHILD - change user and run editor
    304      */
    305     char *ptr;
    306     char visual[1024];
    307 
    308     if (ChangeUser(user, 1) < 0)
    309         exit(0);
    310     if ((ptr = getenv("VISUAL")) == NULL || strlen(ptr) > 256)
    311         ptr = PATH_VI;
    312 
    313     snprintf(visual, sizeof(visual), "%s %s", ptr, file);
    314     execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", visual, NULL);
    315     perror("exec");
    316     exit(0);
    317     }
    318     if (pid < 0) {
    319     /*
    320      * PARENT - failure
    321      */
    322     bb_perror_msg_and_die("fork");
    323     }
    324     wait4(pid, NULL, 0, NULL);
     288    int pid = fork();
     289
     290    if (pid == 0) {
     291        /*
     292         * CHILD - change user and run editor
     293         */
     294        const char *ptr;
     295
     296        if (ChangeUser(user, 1) < 0)
     297            exit(0);
     298        ptr = getenv("VISUAL");
     299        if (ptr == NULL)
     300            ptr = getenv("EDITOR");
     301        if (ptr == NULL)
     302            ptr = PATH_VI;
     303
     304        ptr = xasprintf("%s %s", ptr, file);
     305        execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", ptr, NULL);
     306        bb_perror_msg_and_die("exec");
     307    }
     308    if (pid < 0) {
     309        /*
     310         * PARENT - failure
     311         */
     312        bb_perror_msg_and_die("fork");
     313    }
     314    wait4(pid, NULL, 0, NULL);
    325315}
    326316
    327 static int
    328 ChangeUser(const char *user, short dochdir)
     317static int ChangeUser(const char *user, short dochdir)
    329318{
    330     struct passwd *pas;
    331 
    332     /*
    333     * Obtain password entry and change privileges
    334     */
    335 
    336     if ((pas = getpwnam(user)) == NULL) {
    337     bb_perror_msg_and_die("failed to get uid for %s", user);
    338     return(-1);
    339     }
    340     setenv("USER", pas->pw_name, 1);
    341     setenv("HOME", pas->pw_dir, 1);
    342     setenv("SHELL", DEFAULT_SHELL, 1);
    343 
    344     /*
    345     * Change running state to the user in question
    346     */
    347     change_identity(pas);
    348 
    349     if (dochdir) {
    350     if (chdir(pas->pw_dir) < 0) {
    351         bb_perror_msg("chdir failed: %s %s", user, pas->pw_dir);
    352         bb_xchdir(TMPDIR);
    353     }
    354     }
    355     return(pas->pw_uid);
     319    struct passwd *pas;
     320
     321    /*
     322    * Obtain password entry and change privileges
     323    */
     324
     325    pas = getpwnam(user);
     326    if (pas == NULL) {
     327        bb_perror_msg_and_die("failed to get uid for %s", user);
     328    }
     329    setenv("USER", pas->pw_name, 1);
     330    setenv("HOME", pas->pw_dir, 1);
     331    setenv("SHELL", DEFAULT_SHELL, 1);
     332
     333    /*
     334    * Change running state to the user in question
     335    */
     336    change_identity(pas);
     337
     338    if (dochdir) {
     339        if (chdir(pas->pw_dir) < 0) {
     340            bb_perror_msg("chdir(%s) by %s failed", pas->pw_dir, user);
     341            xchdir(TMPDIR);
     342        }
     343    }
     344    return pas->pw_uid;
    356345}
Note: See TracChangeset for help on using the changeset viewer.