Skip to content

resolve fetch https #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: wipbsd-12
Choose a base branch
from
156 changes: 91 additions & 65 deletions bin/setfacl/setfacl.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fts.h>

#include "setfacl.h"

Expand All @@ -59,35 +60,13 @@ struct sf_entry {
};
static TAILQ_HEAD(, sf_entry) entrylist;

/* TAILQ entry for files */
struct sf_file {
const char *filename;
TAILQ_ENTRY(sf_file) next;
};
static TAILQ_HEAD(, sf_file) filelist;

uint have_mask;
uint need_mask;
uint have_stdin;
uint n_flag;

static void add_filename(const char *filename);
static void usage(void);

static void
add_filename(const char *filename)
{
struct sf_file *file;

if (strlen(filename) > PATH_MAX - 1) {
warn("illegal filename");
return;
}
file = zmalloc(sizeof(struct sf_file));
file->filename = filename;
TAILQ_INSERT_TAIL(&filelist, file, next);
}

static void
usage(void)
{
Expand All @@ -104,22 +83,24 @@ main(int argc, char *argv[])
acl_type_t acl_type;
acl_entry_t unused_entry;
char filename[PATH_MAX];
int local_error, carried_error, ch, i, entry_number, ret;
int h_flag;
struct sf_file *file;
int local_error, carried_error, ch, entry_number, ret, fts_options;
int R_flag, h_flag;
struct sf_entry *entry;
const char *fn_dup;
char *fn_dup;
char *end;
struct stat sb;
FTS *ftsp;
FTSENT *p;
char ** filelist;
size_t size, len;

acl_type = ACL_TYPE_ACCESS;
carried_error = local_error = 0;
h_flag = have_mask = have_stdin = n_flag = need_mask = 0;
R_flag = h_flag = have_mask = have_stdin = n_flag = need_mask = 0;

TAILQ_INIT(&entrylist);
TAILQ_INIT(&filelist);

while ((ch = getopt(argc, argv, "M:X:a:bdhkm:nx:")) != -1)
while ((ch = getopt(argc, argv, "M:RX:a:bdhkm:nx:")) != -1)
switch(ch) {
case 'M':
entry = zmalloc(sizeof(struct sf_entry));
Expand All @@ -129,6 +110,9 @@ main(int argc, char *argv[])
entry->op = OP_MERGE_ACL;
TAILQ_INSERT_TAIL(&entrylist, entry, next);
break;
case 'R':
R_flag = 1;
break;
case 'X':
entry = zmalloc(sizeof(struct sf_entry));
entry->acl = get_acl_from_file(optarg);
Expand Down Expand Up @@ -213,43 +197,85 @@ main(int argc, char *argv[])
err(1, "cannot have more than one stdin");
have_stdin = 1;
bzero(&filename, sizeof(filename));
size = 16;
len = 0;
filelist = realloc(NULL, sizeof(char *) * size);
while (fgets(filename, (int)sizeof(filename), stdin)) {
/* remove the \n */
filename[strlen(filename) - 1] = '\0';
fn_dup = strdup(filename);
if (fn_dup == NULL)
err(1, "strdup() failed");
add_filename(fn_dup);
//filelist
filelist[len++] = fn_dup;
if (size == len) {
filelist = realloc(filelist, sizeof(char *) * (size += 16));
if (!filelist) {
err(1, "realloc() failed");
}
}
}
} else
for (i = 0; i < argc; i++)
add_filename(argv[i]);

/* cycle through each file */
TAILQ_FOREACH(file, &filelist, next) {
filelist = realloc(filelist, sizeof(char *) * len);
} else {
filelist = argv;
}

if (R_flag) {
if (h_flag)
errx(1, "the -R and -h options may not be "
"specified together.");
fts_options = FTS_PHYSICAL;
} else {
fts_options = FTS_LOGICAL;
}

if ((ftsp = fts_open(filelist, fts_options, 0)) == NULL)
err(1, "fts_open");
for (ret = 0;(p = fts_read(ftsp)) != NULL;) {
switch(p->fts_info) {
case FTS_D:
if (!R_flag)
fts_set(ftsp,p,FTS_SKIP);
break;
case FTS_DNR:
warnx("%s: %s", p->fts_accpath, strerror(p->fts_errno));
ret = 1;
break;
case FTS_DP:
continue;
case FTS_ERR:
case FTS_NS:
warnx("%s: %s", p->fts_accpath, strerror(p->fts_errno));
ret = 1;
continue;
default:
break;
}

/* cycle through each file */
local_error = 0;

if (stat(file->filename, &sb) == -1) {
warn("%s: stat() failed", file->filename);
if (stat(p->fts_accpath, &sb) == -1) {
warn("%s: stat() failed", p->fts_accpath);
carried_error++;
continue;
}

if (acl_type == ACL_TYPE_DEFAULT && S_ISDIR(sb.st_mode) == 0) {
warnx("%s: default ACL may only be set on a directory",
file->filename);
p->fts_accpath);
carried_error++;
continue;
}

if (h_flag)
ret = lpathconf(file->filename, _PC_ACL_NFS4);
ret = lpathconf(p->fts_accpath, _PC_ACL_NFS4);
else
ret = pathconf(file->filename, _PC_ACL_NFS4);
ret = pathconf(p->fts_accpath, _PC_ACL_NFS4);
if (ret > 0) {
if (acl_type == ACL_TYPE_DEFAULT) {
warnx("%s: there are no default entries "
"in NFSv4 ACLs", file->filename);
"in NFSv4 ACLs", p->fts_accpath);
carried_error++;
continue;
}
Expand All @@ -259,20 +285,20 @@ main(int argc, char *argv[])
acl_type = ACL_TYPE_ACCESS;
} else if (ret < 0 && errno != EINVAL) {
warn("%s: pathconf(..., _PC_ACL_NFS4) failed",
file->filename);
p->fts_accpath);
}

if (h_flag)
acl = acl_get_link_np(file->filename, acl_type);
acl = acl_get_link_np(p->fts_accpath, acl_type);
else
acl = acl_get_file(file->filename, acl_type);
acl = acl_get_file(p->fts_accpath, acl_type);
if (acl == NULL) {
if (h_flag)
warn("%s: acl_get_link_np() failed",
file->filename);
p->fts_accpath);
else
warn("%s: acl_get_file() failed",
file->filename);
p->fts_accpath);
carried_error++;
continue;
}
Expand All @@ -285,11 +311,11 @@ main(int argc, char *argv[])
switch(entry->op) {
case OP_ADD_ACL:
local_error += add_acl(entry->acl,
entry->entry_number, &acl, file->filename);
entry->entry_number, &acl, p->fts_accpath);
break;
case OP_MERGE_ACL:
local_error += merge_acl(entry->acl, &acl,
file->filename);
p->fts_accpath);
need_mask = 1;
break;
case OP_REMOVE_EXT:
Expand All @@ -301,37 +327,37 @@ main(int argc, char *argv[])
acl_get_entry(acl, ACL_FIRST_ENTRY,
&unused_entry) == 0) {
local_error += remove_default(&acl,
file->filename);
p->fts_accpath);
break;
}
remove_ext(&acl, file->filename);
remove_ext(&acl, p->fts_accpath);
need_mask = 0;
break;
case OP_REMOVE_DEF:
if (acl_type == ACL_TYPE_NFS4) {
warnx("%s: there are no default entries in NFSv4 ACLs; "
"cannot remove", file->filename);
"cannot remove", p->fts_accpath);
local_error++;
break;
}
if (acl_delete_def_file(file->filename) == -1) {
if (acl_delete_def_file(p->fts_accpath) == -1) {
warn("%s: acl_delete_def_file() failed",
file->filename);
p->fts_accpath);
local_error++;
}
if (acl_type == ACL_TYPE_DEFAULT)
local_error += remove_default(&acl,
file->filename);
p->fts_accpath);
need_mask = 0;
break;
case OP_REMOVE_ACL:
local_error += remove_acl(entry->acl, &acl,
file->filename);
p->fts_accpath);
need_mask = 1;
break;
case OP_REMOVE_BY_NUMBER:
local_error += remove_by_number(entry->entry_number,
&acl, file->filename);
&acl, p->fts_accpath);
need_mask = 1;
break;
}
Expand All @@ -343,9 +369,9 @@ main(int argc, char *argv[])
*/
if (acl_type == ACL_TYPE_DEFAULT &&
acl_get_entry(acl, ACL_FIRST_ENTRY, &unused_entry) == 0) {
if (acl_delete_def_file(file->filename) == -1) {
if (acl_delete_def_file(p->fts_accpath) == -1) {
warn("%s: acl_delete_def_file() failed",
file->filename);
p->fts_accpath);
carried_error++;
}
continue;
Expand All @@ -358,22 +384,22 @@ main(int argc, char *argv[])
}

if (acl_type != ACL_TYPE_NFS4 && need_mask &&
set_acl_mask(&acl, file->filename) == -1) {
warnx("%s: failed to set ACL mask", file->filename);
set_acl_mask(&acl, p->fts_accpath) == -1) {
warnx("%s: failed to set ACL mask", p->fts_accpath);
carried_error++;
} else if (h_flag) {
if (acl_set_link_np(file->filename, acl_type,
if (acl_set_link_np(p->fts_accpath, acl_type,
acl) == -1) {
carried_error++;
warn("%s: acl_set_link_np() failed",
file->filename);
p->fts_accpath);
}
} else {
if (acl_set_file(file->filename, acl_type,
if (acl_set_file(p->fts_accpath, acl_type,
acl) == -1) {
carried_error++;
warn("%s: acl_set_file() failed",
file->filename);
p->fts_accpath);
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/libc/sys/clock_gettime.2
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ as well as the following values:
.It Dv CLOCK_REALTIME
.It Dv CLOCK_REALTIME_PRECISE
.It Dv CLOCK_REALTIME_FAST
Increments as a wall clock should.
Increments with consideration of leap seconds and leap years.
.It Dv CLOCK_MONOTONIC
.It Dv CLOCK_MONOTONIC_PRECISE
.It Dv CLOCK_MONOTONIC_FAST
Expand Down Expand Up @@ -117,6 +117,8 @@ struct timespec {
};
.Ed
.Pp
Its time represents seconds and nanoseconds since the Epoch.
.Pp
Only the super-user may set the time of day, using only
.Fa CLOCK_REALTIME .
If the system securelevel is greater than 1 (see
Expand Down
2 changes: 1 addition & 1 deletion sys/dev/vt/hw/fb/vt_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ vt_fb_bitblt_text(struct vt_device *vd, const struct vt_window *vw,
c = VTBUF_GET_FIELD(&vw->vw_buf, row, col);
pattern = vtfont_lookup(vf, c);
vt_determine_colors(c,
VTBUF_ISCURSOR(&vw->vw_buf, row, col), &fg, &bg);
VTBUF_ISCURSOR(&vw->vw_buf, row, col) ^ VT_IS_BLINKING((&vw->vw_buf)), &fg, &bg);

vt_fb_bitblt_bitmap(vd, vw,
pattern, NULL, vf->vf_width, vf->vf_height,
Expand Down
2 changes: 1 addition & 1 deletion sys/dev/vt/hw/vga/vt_vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ vga_bitblt_one_text_pixels_block(struct vt_device *vd,
c = VTBUF_GET_FIELD(vb, row, col);
src = vtfont_lookup(vf, c);

vt_determine_colors(c, VTBUF_ISCURSOR(vb, row, col), &fg, &bg);
vt_determine_colors(c, VTBUF_ISCURSOR(vb, row, col) ^ VT_IS_BLINKING(vb), &fg, &bg);
if ((used_colors_list[fg] & 0x1) != 0x1)
used_colors++;
if ((used_colors_list[bg] & 0x2) != 0x2)
Expand Down
8 changes: 8 additions & 0 deletions sys/dev/vt/vt.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#endif

#define VT_CONSWINDOW 0
#define VT_BLINK_SCREEN 0x2222

#if defined(SC_TWOBUTTON_MOUSE) || defined(VT_TWOBUTTON_MOUSE)
#define VT_MOUSE_PASTEBUTTON MOUSE_BUTTON3DOWN /* right button */
Expand Down Expand Up @@ -156,11 +157,14 @@ struct vt_device {
#define VDF_INITIALIZED 0x20 /* vtterm_cnprobe already done. */
#define VDF_MOUSECURSOR 0x40 /* Mouse cursor visible. */
#define VDF_QUIET_BELL 0x80 /* Disable bell. */
#define VDF_VISUAL_BELL 0x100 /* Visual bell. */
#define VDF_DOWNGRADE 0x8000 /* The driver is being downgraded. */
int vd_keyboard; /* (G) Keyboard index. */
unsigned int vd_kbstate; /* (?) Device unit. */
unsigned int vd_unit; /* (c) Device unit. */
int vd_altbrk; /* (?) Alt break seq. state */
unsigned short vd_bell_pitch;
unsigned short vd_bell_duration;
};

#define VD_PASTEBUF(vd) ((vd)->vd_pastebuf.vpb_buf)
Expand Down Expand Up @@ -205,6 +209,7 @@ struct vt_buf {
term_rect_t vb_dirtyrect; /* (b) Dirty rectangle. */
term_char_t *vb_buffer; /* (u) Data buffer. */
term_char_t **vb_rows; /* (u) Array of rows */
unsigned int vb_visual_attr; /*(?) Visual(blink) attr */
};

#ifdef SC_HISTORY_SIZE
Expand Down Expand Up @@ -258,6 +263,8 @@ void vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz);
#define VTBUF_DIRTYCOL(mask, col) \
((mask)->vbm_col & ((uint64_t)1 << ((col) % 64)))
#define VTBUF_SPACE_CHAR(attr) (' ' | (attr))
#define VT_IS_BLINKING(vb) \
(!!(vb->vb_visual_attr & VT_BLINK_SCREEN))

#define VHS_SET 0
#define VHS_CUR 1
Expand Down Expand Up @@ -298,6 +305,7 @@ struct vt_window {
struct proc *vw_proc;
struct vt_mode vw_smode; /* switch mode */
struct callout vw_proc_dead_timer;
struct callout vw_blink_timer;
struct vt_window *vw_switch_to;
};

Expand Down
Loading