static int local_setuid(FsContext *ctx, uid_t uid)

{

    struct passwd *pw;

    gid_t groups[33];

    int ngroups;

    static uid_t cur_uid = -1;



    if (cur_uid == uid) {

        return 0;

    }



    if (setreuid(0, 0)) {

        return -1;

    }



    pw = getpwuid(uid);

    if (pw == NULL) {

        return -1;

    }



    ngroups = 33;

    if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups) == -1) {

        return -1;

    }



    if (setgroups(ngroups, groups)) {

        return -1;

    }



    if (setregid(-1, pw->pw_gid)) {

        return -1;

    }



    if (setreuid(-1, uid)) {

        return -1;

    }



    cur_uid = uid;



    return 0;

}

static int local_setuid(FsContext *ctx, uid_t uid)

{

    struct passwd *pw;

    gid_t groups[33];

    int ngroups;

    static uid_t cur_uid = -1;



    if (cur_uid == uid) {

        return 0;

    }



    if (setreuid(0, 0)) {

        return -1;

    }



    pw = getpwuid(uid);

    if (pw == NULL) {

        return -1;

    }



    ngroups = 33;

    if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups) == -1) {

        return -1;

    }



    if (setgroups(ngroups, groups)) {

        return -1;

    }



    if (setregid(-1, pw->pw_gid)) {

        return -1;

    }



    if (setreuid(-1, uid)) {

        return -1;

    }



    cur_uid = uid;



    return 0;

}

static int FUNC_0(FsContext *VAR_0, uid_t VAR_1)

{

    struct passwd *VAR_2;

    gid_t groups[33];

    int VAR_3;

    static uid_t VAR_4 = -1;



    if (VAR_4 == VAR_1) {

        return 0;

    }



    if (setreuid(0, 0)) {

        return -1;

    }



    VAR_2 = getpwuid(VAR_1);

    if (VAR_2 == NULL) {

        return -1;

    }



    VAR_3 = 33;

    if (getgrouplist(VAR_2->pw_name, VAR_2->pw_gid, groups, &VAR_3) == -1) {

        return -1;

    }



    if (setgroups(VAR_3, groups)) {

        return -1;

    }



    if (setregid(-1, VAR_2->pw_gid)) {

        return -1;

    }



    if (setreuid(-1, VAR_1)) {

        return -1;

    }



    VAR_4 = VAR_1;



    return 0;

}

static int FUNC_0(FsContext *VAR_0, uid_t VAR_1)
{ struct passwd *VAR_2; gid_t groups[33]; int VAR_3; static uid_t VAR_4 = -1; if (VAR_4 == VAR_1) { return 0; } if (setreuid(0, 0)) { return -1; } VAR_2 = getpwuid(VAR_1); if (VAR_2 == NULL) { return -1; } VAR_3 = 33; if (getgrouplist(VAR_2->pw_name, VAR_2->pw_gid, groups, &VAR_3) == -1) { return -1; } if (setgroups(VAR_3, groups)) { return -1; } if (setregid(-1, VAR_2->pw_gid)) { return -1; } if (setreuid(-1, VAR_1)) { return -1; } VAR_4 = VAR_1; return 0; }