Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 877dfc28 authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Lose restorecon to toybox.

Change-Id: I5460f46700011b7733a1d87a9049e828531627be
parent 02f1d80a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ OUR_TOOLS := \
    ps \
    prlimit \
    renice \
    restorecon \
    sendevent \
    setprop \
    start \

toolbox/restorecon.c

deleted100644 → 0
+0 −63
Original line number Diff line number Diff line
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <selinux/selinux.h>
#include <selinux/android.h>

static const char *progname;

static void usage(void)
{
    fprintf(stderr, "usage:  %s [-DFnrRv] pathname...\n", progname);
    exit(1);
}

int restorecon_main(int argc, char **argv)
{
    int ch, i, rc;
    unsigned int flags = 0;

    progname = argv[0];

    do {
        ch = getopt(argc, argv, "DFnrRv");
        if (ch == EOF)
            break;
        switch (ch) {
        case 'D':
            flags |= SELINUX_ANDROID_RESTORECON_DATADATA;
            break;
        case 'F':
            flags |= SELINUX_ANDROID_RESTORECON_FORCE;
            break;
        case 'n':
            flags |= SELINUX_ANDROID_RESTORECON_NOCHANGE;
            break;
        case 'r':
        case 'R':
            flags |= SELINUX_ANDROID_RESTORECON_RECURSE;
            break;
        case 'v':
            flags |= SELINUX_ANDROID_RESTORECON_VERBOSE;
            break;
        default:
            usage();
        }
    } while (1);

    argc -= optind;
    argv += optind;
    if (!argc)
        usage();

    for (i = 0; i < argc; i++) {
        rc = selinux_android_restorecon(argv[i], flags);
        if (rc < 0)
            fprintf(stderr, "Could not restorecon %s:  %s\n", argv[i],
                    strerror(errno));
    }

    return 0;
}