Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/uuencode/uuencode.c
Show All 40 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
/* | /* | ||||
* uuencode [input] output | * uuencode [input] output | ||||
* | * | ||||
* Encode a file so it can be mailed to a remote system. | * Encode a file so it can be mailed to a remote system. | ||||
*/ | */ | ||||
#include <sys/capsicum.h> | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <capsicum_helpers.h> | |||||
#include <err.h> | #include <err.h> | ||||
#include <errno.h> | |||||
#include <libgen.h> | #include <libgen.h> | ||||
#include <resolv.h> | #include <resolv.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
static void encode(void); | static void encode(void); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | #define RW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) | ||||
} | } | ||||
av = argv; | av = argv; | ||||
if (outfile != NULL) { | if (outfile != NULL) { | ||||
output = fopen(outfile, "w+"); | output = fopen(outfile, "w+"); | ||||
if (output == NULL) | if (output == NULL) | ||||
err(1, "unable to open %s for output", outfile); | err(1, "unable to open %s for output", outfile); | ||||
cap_rights_t out_rights; | |||||
cap_rights_init(&out_rights, CAP_FSTAT | CAP_WRITE | CAP_SEEK ); | |||||
if (cap_rights_limit( output->_file, &out_rights )) | |||||
err(1, "unable to limit rights for %s", outfile); | |||||
} else | } else | ||||
output = stdout; | output = stdout; | ||||
emaste: maybe just "Failed to limit stdio"? | |||||
if (caph_limit_stdio() != 0) | |||||
errx(1, "Failed to limit std{in,out,err}"); | |||||
if (cap_enter() < 0 && errno != ENOSYS) | |||||
err(1, "unable to enter capability mode"); | |||||
if (base64) | if (base64) | ||||
base64_encode(); | base64_encode(); | ||||
else | else | ||||
encode(); | encode(); | ||||
if (ferror(output)) | if (ferror(output)) | ||||
errx(1, "write error"); | errx(1, "write error"); | ||||
exit(0); | exit(0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |
maybe just "Failed to limit stdio"?