2 * Routines for handling privileges, e.g. set-UID and set-GID on UNIX.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 2006 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include "privileges.h"
36 * Called when the program starts, to save whatever credential information
40 get_credential_info(void)
45 * For now, we say the program wasn't started with special privileges.
46 * There are ways of running programs with credentials other than those
47 * for the session in which it's run, but I don't know whether that'd be
48 * done with Wireshark/TShark or not.
51 started_with_special_privs(void)
57 * For now, we don't do anything when asked to relinquish special privileges.
60 relinquish_special_privs_perm(void)
66 #ifdef HAVE_SYS_TYPES_H
67 # include <sys/types.h>
74 static uid_t ruid, euid;
75 static gid_t rgid, egid;
78 * Called when the program starts, to save whatever credential information
80 * That'd be the real and effective UID and GID on UNIX.
83 get_credential_info(void)
92 * "Started with special privileges" means "started out set-UID or set-GID".
95 started_with_special_privs(void)
100 return (ruid != euid || rgid != egid);
105 * Permanently relinquish set-UID and set-GID privileges.
106 * Ignore errors for now - if we have the privileges, we should
107 * be able to relinquish them.
110 relinquish_special_privs_perm(void)