Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/util-linux/setarch.c

    r3232 r3621  
    77 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
     9//config:config SETARCH
     10//config:   bool "setarch"
     11//config:   default y
     12//config:   select PLATFORM_LINUX
     13//config:   help
     14//config:     The linux32 utility is used to create a 32bit environment for the
     15//config:     specified program (usually a shell). It only makes sense to have
     16//config:     this util on a system that supports both 64bit and 32bit userland
     17//config:     (like amd64/x86, ppc64/ppc, sparc64/sparc, etc...).
     18
     19//applet:IF_SETARCH(APPLET(setarch, BB_DIR_BIN, BB_SUID_DROP))
     20//applet:IF_SETARCH(APPLET_ODDNAME(linux32, setarch, BB_DIR_BIN, BB_SUID_DROP, linux32))
     21//applet:IF_SETARCH(APPLET_ODDNAME(linux64, setarch, BB_DIR_BIN, BB_SUID_DROP, linux64))
     22
     23//kbuild:lib-$(CONFIG_SETARCH) += setarch.o
    924
    1025//usage:#define setarch_trivial_usage
    11 //usage:       "personality PROG ARGS"
     26//usage:       "PERSONALITY [-R] PROG ARGS"
    1227//usage:#define setarch_full_usage "\n\n"
    13 //usage:       "Personality may be:\n"
    14 //usage:       "    linux32     Set 32bit uname emulation\n"
    15 //usage:       "    linux64     Set 64bit uname emulation"
     28//usage:       "PERSONALITY may be:"
     29//usage:   "\n""    linux32 Set 32bit uname emulation"
     30//usage:   "\n""    linux64 Set 64bit uname emulation"
     31//usage:   "\n"
     32//usage:   "\n""    -R  Disable address space randomization"
    1633//usage:
    1734//usage:#define linux32_trivial_usage NOUSAGE_STR
     
    2138//usage:#define linux64_full_usage ""
    2239
     40#include "libbb.h"
    2341#include <sys/personality.h>
    2442
    25 #include "libbb.h"
     43#ifndef ADDR_NO_RANDOMIZE
     44# define ADDR_NO_RANDOMIZE       0x0040000
     45#endif
    2646
    2747int setarch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    2848int setarch_main(int argc UNUSED_PARAM, char **argv)
    2949{
    30     int pers;
     50    unsigned opts;
     51    unsigned long pers;
    3152
    3253    /* Figure out what personality we are supposed to switch to ...
     
    3657     */
    3758    if (ENABLE_SETARCH && applet_name[0] == 's'
    38      && argv[1] && strncpy(argv[1], "linux", 5)
     59     && argv[1] && is_prefixed_with(argv[1], "linux")
    3960    ) {
    4061        applet_name = argv[1];
     
    4869        bb_show_usage();
    4970
    50     argv++;
    51     if (argv[0] == NULL)
    52         bb_show_usage();
     71    opts = getopt32(argv, "+R"); /* '+': stop at first non-option */
     72    if (opts)
     73        pers |= ADDR_NO_RANDOMIZE;
    5374
    5475    /* Try to set personality */
    55     if (personality(pers) >= 0) {
    56         /* Try to execute the program */
    57         BB_EXECVP(argv[0], argv);
    58     }
     76    if (personality(pers) < 0)
     77        bb_perror_msg_and_die("personality(0x%lx)", pers);
    5978
    60     bb_simple_perror_msg_and_die(argv[0]);
     79    argv += optind;
     80    if (!argv[0])
     81        (--argv)[0] = (char*)"/bin/sh";
     82
     83    /* Try to execute the program */
     84    BB_EXECVP_or_die(argv);
    6185}
Note: See TracChangeset for help on using the changeset viewer.