100 // to buf with len buflen; buf is returned. 101 static char* describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr); 102 103 // A safe implementation of realpath which will not cause a buffer overflow if the resolved path 104 // is longer than PATH_MAX. 105 // On success, returns 'outbuf', which now contains the path. 106 // On error, it will return NULL and set errno. The content of 'outbuf' is undefined. 107 // On truncation error ('outbuf' too small), it will return NULL and set errno to ENAMETOOLONG. 108 static char* realpath(const char* filename, char* outbuf, size_t outbuflen); 109 110 // Returns true if given uid is root. 111 static bool is_root(uid_t uid); 112 113 // Returns true if given uid is effective or root uid. 114 static bool matches_effective_uid_or_root(uid_t uid); 115 116 // Returns true if either given uid is effective uid and given gid is 117 // effective gid, or if given uid is root. 118 static bool matches_effective_uid_and_gid_or_root(uid_t uid, gid_t gid); 119 120 static void print_umask(outputStream* st, mode_t umsk); 121 122 static void print_user_info(outputStream* st); 123 124 #ifdef SUPPORTS_CLOCK_MONOTONIC 125 126 private: 127 // These need to be members so we can access them from inline functions 128 static int (*_clock_gettime)(clockid_t, struct timespec *); 129 static int (*_clock_getres)(clockid_t, struct timespec *); 130 public: 131 static bool supports_monotonic_clock(); 132 static int clock_gettime(clockid_t clock_id, struct timespec *tp); 133 static int clock_getres(clockid_t clock_id, struct timespec *tp); 134 135 #else 136 137 static bool supports_monotonic_clock() { return false; } 138 139 #endif | 100 // to buf with len buflen; buf is returned. 101 static char* describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr); 102 103 // A safe implementation of realpath which will not cause a buffer overflow if the resolved path 104 // is longer than PATH_MAX. 105 // On success, returns 'outbuf', which now contains the path. 106 // On error, it will return NULL and set errno. The content of 'outbuf' is undefined. 107 // On truncation error ('outbuf' too small), it will return NULL and set errno to ENAMETOOLONG. 108 static char* realpath(const char* filename, char* outbuf, size_t outbuflen); 109 110 // Returns true if given uid is root. 111 static bool is_root(uid_t uid); 112 113 // Returns true if given uid is effective or root uid. 114 static bool matches_effective_uid_or_root(uid_t uid); 115 116 // Returns true if either given uid is effective uid and given gid is 117 // effective gid, or if given uid is root. 118 static bool matches_effective_uid_and_gid_or_root(uid_t uid, gid_t gid); 119 120 static struct sigaction *get_preinstalled_handler(int); 121 static void save_preinstalled_handler(int, struct sigaction&); 122 123 static void print_umask(outputStream* st, mode_t umsk); 124 125 static void print_user_info(outputStream* st); 126 127 #ifdef SUPPORTS_CLOCK_MONOTONIC 128 129 private: 130 // These need to be members so we can access them from inline functions 131 static int (*_clock_gettime)(clockid_t, struct timespec *); 132 static int (*_clock_getres)(clockid_t, struct timespec *); 133 public: 134 static bool supports_monotonic_clock(); 135 static int clock_gettime(clockid_t clock_id, struct timespec *tp); 136 static int clock_getres(clockid_t clock_id, struct timespec *tp); 137 138 #else 139 140 static bool supports_monotonic_clock() { return false; } 141 142 #endif |