forked from osmocom/wireshark
Have started_with_special_privs() assert out if get_credential_info() was not
previously called. This prevents the function from always returning TRUE in programs that hadn't called get_credential_info(). Call get_credential_info() in the programs that should have been. svn path=/trunk/; revision=24648daniel/osmux
parent
6367e7c054
commit
d951728e6b
13
capinfos.c
13
capinfos.c
|
@ -212,7 +212,8 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void usage(gboolean is_error)
|
||||
static void
|
||||
usage(gboolean is_error)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
|
@ -271,7 +272,8 @@ failure_message(const char *msg_format, va_list ap)
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
wtap *wth;
|
||||
int err;
|
||||
|
@ -282,7 +284,14 @@ int main(int argc, char *argv[])
|
|||
int status = 0;
|
||||
#ifdef HAVE_PLUGINS
|
||||
char* init_progfile_dir_error;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get credential information for later use.
|
||||
*/
|
||||
get_credential_info();
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
/* Register wiretap plugins */
|
||||
|
||||
if ((init_progfile_dir_error = init_progfile_dir(argv[0]))) {
|
||||
|
|
20
editcap.c
20
editcap.c
|
@ -297,7 +297,8 @@ is_duplicate(guint8* fd, guint32 len) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void usage(void)
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Editcap %s"
|
||||
#ifdef SVNVERSION
|
||||
|
@ -342,7 +343,8 @@ static void usage(void)
|
|||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static void list_capture_types(void) {
|
||||
static void
|
||||
list_capture_types(void) {
|
||||
int i;
|
||||
|
||||
fprintf(stderr, "editcap: The available capture file types for \"F\":\n");
|
||||
|
@ -353,7 +355,8 @@ static void list_capture_types(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void list_encap_types(void) {
|
||||
static void
|
||||
list_encap_types(void) {
|
||||
int i;
|
||||
const char *string;
|
||||
|
||||
|
@ -374,8 +377,8 @@ failure_message(const char *msg_format, va_list ap)
|
|||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
wtap *wth;
|
||||
int i, j, err;
|
||||
|
@ -400,7 +403,14 @@ int main(int argc, char *argv[])
|
|||
gboolean check_ts;
|
||||
#ifdef HAVE_PLUGINS
|
||||
char* init_progfile_dir_error;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get credential information for later use.
|
||||
*/
|
||||
get_credential_info();
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
/* Register wiretap plugins */
|
||||
if ((init_progfile_dir_error = init_progfile_dir(argv[0]))) {
|
||||
g_warning("capinfos: init_progfile_dir(): %s", init_progfile_dir_error);
|
||||
|
|
|
@ -151,6 +151,7 @@ npf_sys_is_running() {
|
|||
|
||||
static uid_t ruid, euid;
|
||||
static gid_t rgid, egid;
|
||||
static gboolean get_credential_info_called = FALSE;
|
||||
|
||||
/*
|
||||
* Called when the program starts, to save whatever credential information
|
||||
|
@ -164,6 +165,8 @@ get_credential_info(void)
|
|||
euid = geteuid();
|
||||
rgid = getgid();
|
||||
egid = getegid();
|
||||
|
||||
get_credential_info_called = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -173,6 +176,7 @@ get_credential_info(void)
|
|||
gboolean
|
||||
started_with_special_privs(void)
|
||||
{
|
||||
g_assert(get_credential_info_called);
|
||||
#ifdef HAVE_ISSETUGID
|
||||
return issetugid();
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue