lkml.org 
[lkml]   [2011]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: Linux capabilities shouldn't be lost during setuid to non-root from root or to another non-root uid from a non-root uid.
    From
    prctl(PR_SET_KEEPCAPS, 1) didn't work since, during setuid to
    non-root, effective bit was lost.

    Please refer to "man prctl".

    I don't know what would happen when I run OpenVPN as non-root with
    cap_setuid, cap_setgid, cap_sys_admin.
    I guess OpenVPN woull fail to generate tun0 interface if it's run as root.
    However, I need to test it to be sure.

    On Mon, Apr 18, 2011 at 3:07 AM, Serge E. Hallyn <serge@hallyn.com> wrote:
    > You need
    >
    >        prctl(PR_SET_KEEPCAPS, 1);
    >
    > man prctl for details.  In particular, see the following example:
    >
    > #include <stdio.h>
    > #include <sys/prctl.h>
    > #include <sys/capability.h>
    >
    > int main()
    > {
    >        cap_t c;
    >        c = cap_get_proc();
    >        printf("uid %d, current caps: %s\n", getuid(), cap_to_text(c, NULL));
    >        cap_free(c);
    >        prctl(PR_SET_KEEPCAPS, 1);
    >        setuid(1001, 1001, 1001);
    >        c = cap_get_proc();
    >        printf("uid %d, current caps: %s\n", getuid(), cap_to_text(c, NULL));
    >        cap_free(c);
    > }
    >
    > You can either run that as root, or you can do
    >
    >        sudo setcap cap_setuid,cap_setgid,cap_sys_admin=eip captest
    >
    > and then run it as non-root.
    >
    > HTH,
    > -serge
    >
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2011-04-18 03:23    [W:0.021 / U:212.796 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site