version 1.1.1.2, 2012/05/29 12:26:49
|
version 1.1.1.5, 2014/06/15 16:12:54
|
Line 1
|
Line 1
|
/* |
/* |
* Copyright (c) 2010-2011 Todd C. Miller <Todd.Miller@courtesan.com> | * Copyright (c) 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 17
|
Line 17
|
#include <config.h> |
#include <config.h> |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/param.h> |
|
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <sys/wait.h> |
#include <sys/wait.h> |
|
|
Line 56
|
Line 55
|
|
|
#include <pathnames.h> |
#include <pathnames.h> |
#include "sudo_plugin.h" |
#include "sudo_plugin.h" |
|
#include "sudo_util.h" |
#include "missing.h" |
#include "missing.h" |
|
|
/* |
/* |
Line 139 policy_open(unsigned int version, sudo_conv_t conversa
|
Line 139 policy_open(unsigned int version, sudo_conv_t conversa
|
if (strncmp(*ui, "runas_group=", sizeof("runas_group=") - 1) == 0) { |
if (strncmp(*ui, "runas_group=", sizeof("runas_group=") - 1) == 0) { |
runas_group = *ui + sizeof("runas_group=") - 1; |
runas_group = *ui + sizeof("runas_group=") - 1; |
} |
} |
#if !defined(HAVE_GETPROGNAME) && !defined(HAVE___PROGNAME) |
|
if (strncmp(*ui, "progname=", sizeof("progname=") - 1) == 0) { |
if (strncmp(*ui, "progname=", sizeof("progname=") - 1) == 0) { |
setprogname(*ui + sizeof("progname=") - 1); | initprogname(*ui + sizeof("progname=") - 1); |
} |
} |
#endif |
|
/* Check to see if sudo was called as sudoedit or with -e flag. */ |
/* Check to see if sudo was called as sudoedit or with -e flag. */ |
if (strncmp(*ui, "sudoedit=", sizeof("sudoedit=") - 1) == 0) { |
if (strncmp(*ui, "sudoedit=", sizeof("sudoedit=") - 1) == 0) { |
if (strcasecmp(*ui + sizeof("sudoedit=") - 1, "true") == 0) |
if (strcasecmp(*ui + sizeof("sudoedit=") - 1, "true") == 0) |
Line 237 check_passwd(void)
|
Line 235 check_passwd(void)
|
} |
} |
|
|
static char ** |
static char ** |
build_command_info(char *command) | build_command_info(const char *command) |
{ |
{ |
static char **command_info; |
static char **command_info; |
int i = 0; |
int i = 0; |
Line 306 find_editor(int nfiles, char * const files[], char **a
|
Line 304 find_editor(int nfiles, char * const files[], char **a
|
cp = strtok(editor, " \t"); |
cp = strtok(editor, " \t"); |
if (cp == NULL || |
if (cp == NULL || |
(editor_path = find_in_path(editor, plugin_state.envp)) == NULL) { |
(editor_path = find_in_path(editor, plugin_state.envp)) == NULL) { |
|
free(editor); |
return NULL; |
return NULL; |
} |
} |
|
if (editor_path != editor) |
|
free(editor); |
nargv = (char **) malloc((nargc + 1 + nfiles + 1) * sizeof(char *)); |
nargv = (char **) malloc((nargc + 1 + nfiles + 1) * sizeof(char *)); |
if (nargv == NULL) { |
if (nargv == NULL) { |
sudo_log(SUDO_CONV_ERROR_MSG, "unable to allocate memory\n"); |
sudo_log(SUDO_CONV_ERROR_MSG, "unable to allocate memory\n"); |
|
free(editor_path); |
return NULL; |
return NULL; |
} |
} |
for (ac = 0; cp != NULL && ac < nargc; ac++) { |
for (ac = 0; cp != NULL && ac < nargc; ac++) { |
Line 357 policy_check(int argc, char * const argv[],
|
Line 359 policy_check(int argc, char * const argv[],
|
|
|
if (use_sudoedit) { |
if (use_sudoedit) { |
/* Rebuild argv using editor */ |
/* Rebuild argv using editor */ |
|
free(command); |
command = find_editor(argc - 1, argv + 1, argv_out); |
command = find_editor(argc - 1, argv + 1, argv_out); |
if (command == NULL) { |
if (command == NULL) { |
sudo_log(SUDO_CONV_ERROR_MSG, "unable to find valid editor\n"); |
sudo_log(SUDO_CONV_ERROR_MSG, "unable to find valid editor\n"); |
Line 373 policy_check(int argc, char * const argv[],
|
Line 376 policy_check(int argc, char * const argv[],
|
|
|
/* Setup command info. */ |
/* Setup command info. */ |
*command_info_out = build_command_info(command); |
*command_info_out = build_command_info(command); |
|
free(command); |
if (*command_info_out == NULL) { |
if (*command_info_out == NULL) { |
sudo_log(SUDO_CONV_ERROR_MSG, "out of memory\n"); |
sudo_log(SUDO_CONV_ERROR_MSG, "out of memory\n"); |
return -1; |
return -1; |
Line 498 struct policy_plugin sample_policy = {
|
Line 502 struct policy_plugin sample_policy = {
|
* Note: This plugin does not differentiate between tty and pipe I/O. |
* Note: This plugin does not differentiate between tty and pipe I/O. |
* It all gets logged to the same file. |
* It all gets logged to the same file. |
*/ |
*/ |
struct io_plugin sample_io = { | __dso_public struct io_plugin sample_io = { |
SUDO_IO_PLUGIN, |
SUDO_IO_PLUGIN, |
SUDO_API_VERSION, |
SUDO_API_VERSION, |
io_open, |
io_open, |