dj(1): tweak OpenBSD functions
This commit is contained in:
parent
b1a4a1a2b9
commit
10b7f7706b
21
src/dj.c
21
src/dj.c
@ -170,12 +170,6 @@ usage(char *argv0) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("cpath rpath stdio unveil wpath", NULL) == -1) {
|
||||
return oserr(NULL", errno);
|
||||
}
|
||||
#endif
|
||||
|
||||
int align; /* low 8b used, negative if no alignment is being done */
|
||||
int count; /* -1 if dj(1) runs until no more reads are possible */
|
||||
char *fmt; /* set to fmt_asv (default) or fmt_human (-H) */
|
||||
@ -183,6 +177,12 @@ int main(int argc, char *argv[]) {
|
||||
bool retry; /* false if exits on partial reads or writes */
|
||||
struct Io io[2 /* { in, out } */];
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("cpath rpath stdio unveil wpath", NULL) == -1) {
|
||||
return oserr(NULL, errno);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set defaults. */
|
||||
align = -1;
|
||||
count = -1;
|
||||
@ -217,13 +217,9 @@ int main(int argc, char *argv[]) {
|
||||
break;
|
||||
} else {
|
||||
int fd;
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
char *perms = "wc";
|
||||
|
||||
/* modify perms in-place to read-only */
|
||||
if (i == 0) { perms = "r"; }
|
||||
|
||||
if (unveil(optarg, perms) == -1) {
|
||||
if (unveil(optarg, i == 0 ? "r" : "wc") == -1) {
|
||||
return oserr(NULL, errno);
|
||||
}
|
||||
#endif
|
||||
@ -267,6 +263,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
if (unveil(NULL, NULL) == -1) { return oserr(NULL, errno); }
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user