1 /* 2 * ProFTPD - FTP server daemon 3 * Copyright (c) 1997, 1998 Public Flood Software 4 * Copyright (c) 1999, 2000 MacGyver aka Habeeb J. Dihu <macgyver@tos.net> 5 * Copyright (c) 2001-2016 The ProFTPD Project team 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. 20 * 21 * As a special exemption, Public Flood Software/MacGyver aka Habeeb J. Dihu 22 * and other respective copyright holders give permission to link this program 23 * with OpenSSL, and distribute the resulting executable, without including 24 * the source code for OpenSSL in the source distribution. 25 */ 26 27 #ifndef PR_PRIVS_H 28 #define PR_PRIVS_H 29 30 #if defined(HPUX10) || defined(HPUX11) 31 # define setreuid(r, e) setresuid((r), (e), 0) 32 #endif /* HPUX */ 33 34 #ifdef PR_DEVEL_COREDUMP 35 /* Unix kernels can be notoriously picky about dumping the core for 36 * processes that have fiddled with their effective/actual UID and GID. 37 * So, to make it possible for people to have their proftpd processes 38 * actually be able to coredump, these PRIVS macros, which switch 39 * privileges, are effectively disabled. 40 * 41 * Hence it is not a Good Idea to run a proftpd built with PR_DEVEL_COREDUMP 42 * defined in production. 43 */ 44 45 # define PRIVS_SETUP(u, g) 46 # define PRIVS_ROOT 47 # define PRIVS_USER 48 # define PRIVS_RELINQUISH 49 # define PRIVS_REVOKE 50 51 #else 52 53 # define PRIVS_SETUP(u, g) pr_privs_setup((u), (g), __FILE__, __LINE__); 54 # define PRIVS_ROOT pr_privs_root(__FILE__, __LINE__); 55 # define PRIVS_USER pr_privs_user(__FILE__, __LINE__); 56 # define PRIVS_RELINQUISH pr_privs_relinquish(__FILE__, __LINE__); 57 # define PRIVS_REVOKE pr_privs_revoke(__FILE__, __LINE__); 58 59 #endif /* PR_DEVEL_COREDUMP */ 60 61 int pr_privs_setup(uid_t, gid_t, const char *, int); 62 int pr_privs_root(const char *, int); 63 int pr_privs_user(const char *, int); 64 int pr_privs_relinquish(const char *, int); 65 int pr_privs_revoke(const char *, int); 66 67 /* For internal use only. */ 68 int init_privs(void); 69 int set_nonroot_daemon(int); 70 71 #endif /* PR_PRIVS_H */ 72