Make sure logs are always ended with newline

This commit is contained in:
topjohnwu
2022-09-09 04:29:50 -07:00
parent 44029875a6
commit a66a3b7438
19 changed files with 76 additions and 47 deletions
+5 -5
View File
@@ -64,7 +64,7 @@ void su_info::check_db() {
if (eval_uid > 0) {
char query[256], *err;
snprintf(query, sizeof(query),
ssprintf(query, sizeof(query),
"SELECT policy, logging, notification FROM policies "
"WHERE uid=%d AND (until=0 OR until>%li)", eval_uid, time(nullptr));
err = db_exec(query, [&](db_row &row) -> bool {
@@ -125,7 +125,7 @@ bool uid_granted_root(int uid) {
bool granted = false;
char query[256], *err;
snprintf(query, sizeof(query),
ssprintf(query, sizeof(query),
"SELECT policy FROM policies WHERE uid=%d AND (until=0 OR until>%li)",
uid, time(nullptr));
err = db_exec(query, [&](db_row &row) -> bool {
@@ -158,7 +158,7 @@ void prune_su_access() {
db_err_cmd(err, return);
for (int uid : rm_uids) {
snprintf(query, sizeof(query), "DELETE FROM policies WHERE uid == %d", uid);
ssprintf(query, sizeof(query), "DELETE FROM policies WHERE uid == %d", uid);
// Don't care about errors
db_exec(query);
}
@@ -410,11 +410,11 @@ void su_daemon_handler(int client, const sock_cred *cred) {
// Setup environment
umask(022);
char path[32];
snprintf(path, sizeof(path), "/proc/%d/cwd", ctx.pid);
ssprintf(path, sizeof(path), "/proc/%d/cwd", ctx.pid);
char cwd[PATH_MAX];
if (realpath(path, cwd))
chdir(cwd);
snprintf(path, sizeof(path), "/proc/%d/environ", ctx.pid);
ssprintf(path, sizeof(path), "/proc/%d/environ", ctx.pid);
auto env = full_read(path);
clearenv();
for (size_t pos = 0; pos < env.size(); ++pos) {