if (S_ISDIR(st->st_mode) &&
(!(f & SF_LAST) || (cp->cp_what & CP_STICKYOK)))
- stickyok = 01000;
+ stickyok = S_ISVTX;
/* --- Check for world-writability --- */
if ((cp->cp_what & CP_WRWORLD) &&
- (st->st_mode & (0002 | stickyok)) == 0002) {
+ (st->st_mode & (S_IWOTH | stickyok)) == S_IWOTH) {
bad |= CP_WRWORLD;
report(cp, CP_WRWORLD, 1, p, "** world writable **");
}
/* --- Check for group-writability --- */
if ((cp->cp_what & (CP_WRGRP | CP_WROTHGRP)) &&
- (st->st_mode & (0020 | stickyok)) == 0020) {
+ (st->st_mode & (S_IWGRP | stickyok)) == S_IWGRP) {
b = CP_WRGRP;
if (cp->cp_what & CP_WROTHGRP) {
struct elt *e, *ee;
struct stat st;
unsigned bad = 0;
+ dstr buf = DSTR_INIT;
/* --- Initialize stack pointer and path string --- */
/* --- Handle symbolic links specially --- */
if (S_ISLNK(st.st_mode)) {
- dstr buf = DSTR_INIT;
int i;
/* --- Resolve the link --- */
+ dstr_reset(&buf);
dstr_ensure(&buf, st.st_size + 1);
if ((i = readlink(d.buf, buf.buf, buf.sz)) < 0) {
report(cp, CP_ERROR, 0, d.buf, "can't readlink: %e");
else
pop();
ee = splitpath(buf.buf, ee);
- dstr_destroy(&buf);
continue;
}
bad |= sanity(d.buf, &st, cp, ee ? 0 : SF_LAST);
if (S_ISDIR(st.st_mode)) {
- if (st.st_mode & 01000)
+ if (st.st_mode & S_ISVTX)
sp->e_flags |= EF_STICKY;
report(cp, CP_REPORT, 4, d.buf, "directory");
continue;
}
popall();
+ dstr_destroy(&buf);
return (bad);
}