Changeset 427 for vendor/current/source3/lib/system.c
- Timestamp:
- Apr 9, 2010, 3:20:58 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/system.c
r414 r427 884 884 #if defined(HAVE_POSIX_CAPABILITIES) 885 885 886 /* This define hasn't made it into the glibc capabilities header yet. */887 #ifndef SECURE_NO_SETUID_FIXUP888 #define SECURE_NO_SETUID_FIXUP 2889 #endif890 891 886 /************************************************************************** 892 887 Try and abstract process capabilities (for systems that have them). … … 919 914 #endif 920 915 921 #if defined(HAVE_PRCTL) && defined(PR_SET_SECUREBITS) && defined(SECURE_NO_SETUID_FIXUP)922 /* New way of setting capabilities as "sticky". */923 924 /*925 * Use PR_SET_SECUREBITS to prevent setresuid()926 * atomically dropping effective capabilities on927 * uid change. Only available in Linux kernels928 * 2.6.26 and above.929 *930 * See here:931 * http://www.kernel.org/doc/man-pages/online/pages/man7/capabilities.7.html932 * for details.933 *934 * Specifically the CAP_KILL capability we need935 * to allow Linux threads under different euids936 * to send signals to each other.937 */938 939 if (prctl(PR_SET_SECUREBITS, 1 << SECURE_NO_SETUID_FIXUP)) {940 DEBUG(0,("set_process_capability: "941 "prctl PR_SET_SECUREBITS failed with error %s\n",942 strerror(errno) ));943 return false;944 }945 #endif946 947 916 cap = cap_get_proc(); 948 917 if (cap == NULL) { … … 973 942 #endif 974 943 break; 975 case KILL_CAPABILITY:976 #ifdef CAP_KILL977 cap_vals[num_cap_vals++] = CAP_KILL;978 #endif979 break;980 944 } 981 945 … … 987 951 } 988 952 989 /* 990 * Ensure the capability is effective. We assume that as a root 991 * process it's always permitted. 992 */ 993 994 if (cap_set_flag(cap, CAP_EFFECTIVE, num_cap_vals, cap_vals, 995 enable ? CAP_SET : CAP_CLEAR) == -1) { 996 DEBUG(0, ("set_process_capability: cap_set_flag effective " 997 "failed (%d): %s\n", 998 (int)capability, 999 strerror(errno))); 1000 cap_free(cap); 1001 return false; 1002 } 953 cap_set_flag(cap, CAP_EFFECTIVE, num_cap_vals, cap_vals, 954 enable ? CAP_SET : CAP_CLEAR); 1003 955 1004 956 /* We never want to pass capabilities down to our children, so make 1005 957 * sure they are not inherited. 1006 958 */ 1007 if (cap_set_flag(cap, CAP_INHERITABLE, num_cap_vals, 1008 cap_vals, CAP_CLEAR) == -1) { 1009 DEBUG(0, ("set_process_capability: cap_set_flag inheritable " 1010 "failed (%d): %s\n", 1011 (int)capability, 1012 strerror(errno))); 1013 cap_free(cap); 1014 return false; 1015 } 959 cap_set_flag(cap, CAP_INHERITABLE, num_cap_vals, cap_vals, CAP_CLEAR); 1016 960 1017 961 if (cap_set_proc(cap) == -1) { 1018 DEBUG(0, ("set_process_capability: cap_set_flag (%d) failed: %s\n", 1019 (int)capability, 962 DEBUG(0, ("set_process_capability: cap_set_proc failed: %s\n", 1020 963 strerror(errno))); 1021 964 cap_free(cap);
Note:
See TracChangeset
for help on using the changeset viewer.