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