Ignore:
Timestamp:
Mar 1, 2010, 3:05:48 PM (15 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3.x to 3.3.11

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/lib/system.c

    r309 r411  
    708708#if defined(HAVE_POSIX_CAPABILITIES)
    709709
     710/* This define hasn't made it into the glibc capabilities header yet. */
     711#ifndef SECURE_NO_SETUID_FIXUP
     712#define SECURE_NO_SETUID_FIXUP          2
     713#endif
     714
    710715/**************************************************************************
    711716 Try and abstract process capabilities (for systems that have them).
     
    738743#endif
    739744
     745#if defined(HAVE_PRCTL) && defined(PR_SET_SECUREBITS) && defined(SECURE_NO_SETUID_FIXUP)
     746        /* New way of setting capabilities as "sticky". */
     747
     748        /*
     749         * Use PR_SET_SECUREBITS to prevent setresuid()
     750         * atomically dropping effective capabilities on
     751         * uid change. Only available in Linux kernels
     752         * 2.6.26 and above.
     753         *
     754         * See here:
     755         * http://www.kernel.org/doc/man-pages/online/pages/man7/capabilities.7.html
     756         * for details.
     757         *
     758         * Specifically the CAP_KILL capability we need
     759         * to allow Linux threads under different euids
     760         * to send signals to each other.
     761         */
     762
     763        if (prctl(PR_SET_SECUREBITS, 1 << SECURE_NO_SETUID_FIXUP)) {
     764                DEBUG(0,("set_process_capability: "
     765                        "prctl PR_SET_SECUREBITS failed with error %s\n",
     766                        strerror(errno) ));
     767                return false;
     768        }
     769#endif
     770
    740771        cap = cap_get_proc();
    741772        if (cap == NULL) {
     
    766797#endif
    767798                        break;
     799                case KILL_CAPABILITY:
     800#ifdef CAP_KILL
     801                        cap_vals[num_cap_vals++] = CAP_KILL;
     802#endif
     803                        break;
    768804        }
    769805
     
    775811        }
    776812
    777         cap_set_flag(cap, CAP_EFFECTIVE, num_cap_vals, cap_vals,
    778                 enable ? CAP_SET : CAP_CLEAR);
     813        /*
     814         * Ensure the capability is effective. We assume that as a root
     815         * process it's always permitted.
     816         */
     817
     818        if (cap_set_flag(cap, CAP_EFFECTIVE, num_cap_vals, cap_vals,
     819                        enable ? CAP_SET : CAP_CLEAR) == -1) {
     820                DEBUG(0, ("set_process_capability: cap_set_flag effective "
     821                        "failed (%d): %s\n",
     822                        (int)capability,
     823                        strerror(errno)));
     824                cap_free(cap);
     825                return false;
     826        }
    779827
    780828        /* We never want to pass capabilities down to our children, so make
    781829         * sure they are not inherited.
    782830         */
    783         cap_set_flag(cap, CAP_INHERITABLE, num_cap_vals, cap_vals, CAP_CLEAR);
     831        if (cap_set_flag(cap, CAP_INHERITABLE, num_cap_vals,
     832                        cap_vals, CAP_CLEAR) == -1) {
     833                DEBUG(0, ("set_process_capability: cap_set_flag inheritable "
     834                        "failed (%d): %s\n",
     835                        (int)capability,
     836                        strerror(errno)));
     837                cap_free(cap);
     838                return false;
     839        }
    784840
    785841        if (cap_set_proc(cap) == -1) {
    786                 DEBUG(0, ("set_process_capability: cap_set_proc failed: %s\n",
     842                DEBUG(0, ("set_process_capability: cap_set_flag (%d) failed: %s\n",
     843                        (int)capability,
    787844                        strerror(errno)));
    788845                cap_free(cap);
Note: See TracChangeset for help on using the changeset viewer.