Make indent

This commit is contained in:
Robert Swiecki 2016-10-12 00:59:10 +02:00
parent 047c94e2d9
commit a30e2f107c
3 changed files with 28 additions and 23 deletions

View File

@ -123,19 +123,19 @@ void cmdlineLogParams(struct nsjconf_t *nsjconf)
struct mounts_t *p;
TAILQ_FOREACH(p, &nsjconf->mountpts, pointers) {
LOG_I("Mount point: src:'%s' dst:'%s' type:'%s' flags:0x%tx options:'%s'",
p->src, p->dst, p->fs_type, p->flags, p->options);
p->src, p->dst, p->fs_type, p->flags, p->options);
}
}
{
struct mapping_t *p;
TAILQ_FOREACH(p, &nsjconf->uid_mappings, pointers) {
LOG_I("Uid mapping: inside_uid:'%s' outside_uid:'%s' count:'%s'",
p->inside_id, p->outside_id, p->count);
p->inside_id, p->outside_id, p->count);
}
TAILQ_FOREACH(p, &nsjconf->gid_mappings, pointers) {
LOG_I("Gid mapping: inside_uid:'%s' outside_uid:'%s' count:'%s'",
p->inside_id, p->outside_id, p->count);
p->inside_id, p->outside_id, p->count);
}
}
}

3
log.c
View File

@ -54,7 +54,8 @@ bool logInitLogFile(struct nsjconf_t *nsjconf, const char *logfile, bool is_verb
if (logfile == NULL) {
log_fd = STDERR_FILENO;
} else {
if (TEMP_FAILURE_RETRY(log_fd = open(logfile, O_CREAT | O_RDWR | O_APPEND, 0640)) == -1) {
if (TEMP_FAILURE_RETRY(log_fd = open(logfile, O_CREAT | O_RDWR | O_APPEND, 0640)) ==
-1) {
log_fd = STDERR_FILENO;
PLOG_E("Couldn't open logfile open('%s')", logfile);
return false;

42
user.c
View File

@ -54,7 +54,8 @@ static bool userSetGroups(pid_t pid)
return true;
}
static bool userUidMapSelf(struct nsjconf_t *nsjconf, pid_t pid) {
static bool userUidMapSelf(struct nsjconf_t *nsjconf, pid_t pid)
{
char fname[PATH_MAX];
char map[128];
@ -70,7 +71,8 @@ static bool userUidMapSelf(struct nsjconf_t *nsjconf, pid_t pid) {
return true;
}
static bool userGidMapSelf(struct nsjconf_t *nsjconf, pid_t pid) {
static bool userGidMapSelf(struct nsjconf_t *nsjconf, pid_t pid)
{
char fname[PATH_MAX];
char map[128];
@ -86,16 +88,17 @@ static bool userGidMapSelf(struct nsjconf_t *nsjconf, pid_t pid) {
}
// use /usr/bin/newgidmap for writing the uid and gid map
static bool userGidMapExternal(struct nsjconf_t *nsjconf, pid_t pid) {
static bool userGidMapExternal(struct nsjconf_t *nsjconf, pid_t pid)
{
char cmd_buf[1024];
char *cmd_ptr = cmd_buf;
size_t len = sizeof(cmd_buf);
int write_size;
write_size = snprintf(cmd_ptr, len, "/usr/bin/newgidmap %lu %lu %lu 1",
(unsigned long)pid,
(unsigned long)nsjconf->inside_gid,
(unsigned long)nsjconf->outside_gid);
(unsigned long)pid,
(unsigned long)nsjconf->inside_gid,
(unsigned long)nsjconf->outside_gid);
if (write_size <= 0 || (size_t) write_size > len) {
LOG_E("snprintf writing the new{u,g}idmap command failed");
return false;
@ -106,8 +109,8 @@ static bool userGidMapExternal(struct nsjconf_t *nsjconf, pid_t pid) {
struct mapping_t *p;
TAILQ_FOREACH(p, &nsjconf->gid_mappings, pointers) {
write_size = snprintf(cmd_ptr, len, " %s %s %s",
p->inside_id, p->outside_id, p->count);
if (write_size <= 0 || (size_t) write_size > len) {
p->inside_id, p->outside_id, p->count);
if (write_size <= 0 || (size_t) write_size > len) {
LOG_E("snprintf writing the new{u,g}idmap command failed");
return false;
}
@ -116,25 +119,26 @@ static bool userGidMapExternal(struct nsjconf_t *nsjconf, pid_t pid) {
}
if (system(cmd_buf) != 0) {
LOG_E("system('%s') failed", cmd_buf);
while(1) ;
return false;
LOG_E("system('%s') failed", cmd_buf);
while (1) ;
return false;
}
return true;
}
// use /usr/bin/newuidmap for writing the uid and gid map
static bool userUidMapExternal(struct nsjconf_t *nsjconf, pid_t pid) {
static bool userUidMapExternal(struct nsjconf_t *nsjconf, pid_t pid)
{
char cmd_buf[1024];
char *cmd_ptr = cmd_buf;
size_t len = sizeof(cmd_buf);
int write_size;
write_size = snprintf(cmd_ptr, len, "/usr/bin/newuidmap %lu %lu %lu 1",
(unsigned long)pid,
(unsigned long)nsjconf->inside_uid,
(unsigned long)nsjconf->outside_uid);
(unsigned long)pid,
(unsigned long)nsjconf->inside_uid,
(unsigned long)nsjconf->outside_uid);
if (write_size <= 0 || (size_t) write_size > len) {
LOG_E("snprintf writing the new{u,g}idmap command failed");
return false;
@ -145,8 +149,8 @@ static bool userUidMapExternal(struct nsjconf_t *nsjconf, pid_t pid) {
struct mapping_t *p;
TAILQ_FOREACH(p, &nsjconf->uid_mappings, pointers) {
write_size = snprintf(cmd_ptr, len, " %s %s %s",
p->inside_id, p->outside_id, p->count);
if (write_size <= 0 || (size_t) write_size > len) {
p->inside_id, p->outside_id, p->count);
if (write_size <= 0 || (size_t) write_size > len) {
LOG_E("snprintf writing the new{u,g}idmap command failed");
return false;
}
@ -155,8 +159,8 @@ static bool userUidMapExternal(struct nsjconf_t *nsjconf, pid_t pid) {
}
if (system(cmd_buf) != 0) {
LOG_E("system('%s') failed", cmd_buf);
return false;
LOG_E("system('%s') failed", cmd_buf);
return false;
}
return true;