144 |
#include "manp.h" |
#include "manp.h" |
145 |
#include "security.h" |
#include "security.h" |
146 |
#include "encodings.h" |
#include "encodings.h" |
147 |
|
#include "convert_name.h" |
148 |
#include "man.h" |
#include "man.h" |
149 |
|
|
150 |
#ifdef SECURE_MAN_UID |
#ifdef SECURE_MAN_UID |
487 |
static struct termios tms; |
static struct termios tms; |
488 |
static int tms_set = 0; |
static int tms_set = 0; |
489 |
|
|
490 |
void set_term () |
static void set_term (void) |
491 |
{ |
{ |
492 |
if (tms_set) |
if (tms_set) |
493 |
tcsetattr (0, TCSANOW, &tms); |
tcsetattr (0, TCSANOW, &tms); |
494 |
} |
} |
495 |
|
|
496 |
void get_term() |
static void get_term (void) |
497 |
{ |
{ |
498 |
if (isatty (1)) { |
if (isatty (1)) { |
499 |
if (debug) |
if (debug) |
861 |
return exit_status; |
return exit_status; |
862 |
} |
} |
863 |
|
|
864 |
|
static void int_handler (int signo) |
865 |
|
{ |
866 |
|
if (debug) |
867 |
|
fprintf (stderr, "\ninterrupt signal %d handler\n", signo); |
868 |
|
exit (INTERRUPTED); |
869 |
|
} |
870 |
|
|
871 |
int main (int argc, char *argv[]) |
int main (int argc, char *argv[]) |
872 |
{ |
{ |
873 |
int argc_env, exit_status = OK; |
int argc_env, exit_status = OK; |
875 |
const char *tmp; |
const char *tmp; |
876 |
char *multiple_locale = NULL; |
char *multiple_locale = NULL; |
877 |
extern int optind; |
extern int optind; |
|
void (int_handler) (int); |
|
878 |
|
|
879 |
program_name = xstrdup (basename (argv[0])); |
program_name = xstrdup (basename (argv[0])); |
880 |
|
|
946 |
if (external) |
if (external) |
947 |
do_extern (argv); |
do_extern (argv); |
948 |
|
|
949 |
get_term(); /* stores terminal settings */ |
get_term (); /* stores terminal settings */ |
950 |
#ifdef SECURE_MAN_UID |
#ifdef SECURE_MAN_UID |
951 |
if (debug) |
if (debug) |
952 |
fprintf (stderr, "real user = %d; effective user = %d\n", |
fprintf (stderr, "real user = %d; effective user = %d\n", |
1505 |
/* Ignore SIGPIPE; we want to be notified by write returning |
/* Ignore SIGPIPE; we want to be notified by write returning |
1506 |
* EPIPE. |
* EPIPE. |
1507 |
*/ |
*/ |
1508 |
RETSIGTYPE (*old_handler)() = signal (SIGPIPE, SIG_IGN); |
RETSIGTYPE (*old_handler)(int) = signal (SIGPIPE, SIG_IGN); |
1509 |
|
|
1510 |
/* read data into bf; we don't want to use the stream stuff |
/* read data into bf; we don't want to use the stream stuff |
1511 |
* because we don't want data to be lost in the buffers, not |
* because we don't want data to be lost in the buffers, not |
2026 |
|
|
2027 |
tmp_cat_file = tmp_cat_filename (cat_file); |
tmp_cat_file = tmp_cat_filename (cat_file); |
2028 |
if (!debug) |
if (!debug) |
2029 |
push_cleanup ((void (*)()) unlink, tmp_cat_file); |
push_cleanup ((cleanup_fun) unlink, tmp_cat_file); |
2030 |
created_tmp_cat = 0; |
created_tmp_cat = 0; |
2031 |
|
|
2032 |
# ifdef COMP_CAT |
# ifdef COMP_CAT |
2173 |
FILE *out = checked_popen (disp_cmd, "w"); |
FILE *out = checked_popen (disp_cmd, "w"); |
2174 |
FILE *sav = open_cat_stream (cat_file); |
FILE *sav = open_cat_stream (cat_file); |
2175 |
int instat = 1, outstat; |
int instat = 1, outstat; |
2176 |
RETSIGTYPE (*old_handler)() = signal (SIGPIPE, SIG_IGN); |
RETSIGTYPE (*old_handler)(int) = signal (SIGPIPE, SIG_IGN); |
2177 |
|
|
2178 |
if (in && out) { |
if (in && out) { |
2179 |
/* copy in to both out and sav */ |
/* copy in to both out and sav */ |
2341 |
* (2) else depending on ruid's privs is ok, effectively disables |
* (2) else depending on ruid's privs is ok, effectively disables |
2342 |
* catman for non-root. |
* catman for non-root. |
2343 |
*/ |
*/ |
2344 |
push_cleanup ((void (*)()) unlink, tmpcat); |
push_cleanup ((cleanup_fun) unlink, tmpcat); |
2345 |
status = do_system_drop_privs (cmd); |
status = do_system_drop_privs (cmd); |
2346 |
if (status) |
if (status) |
2347 |
gripe_system (cmd, status); |
gripe_system (cmd, status); |
3436 |
|
|
3437 |
return 0; |
return 0; |
3438 |
} |
} |
|
|
|
|
void int_handler (int signo) |
|
|
{ |
|
|
if (debug) |
|
|
fprintf (stderr, "\ninterrupt signal %d handler\n", signo); |
|
|
exit (INTERRUPTED); |
|
|
} |
|