Skip to content

Commit b757449

Browse files
thevihanraixfeep
authored andcommitted
Update ngx_http_clojure_module.c
when checking accessibility of jvm classpath, print user id instead of user name in debug logs. This is to support containerised environments where user id is randomly assigned from range and username may not be available
1 parent 49c0af4 commit b757449

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/c/ngx_http_clojure_module.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,23 +1670,20 @@ static ngx_int_t ngx_http_clojure_check_access_jvm_cp(ngx_http_clojure_main_conf
16701670
return NGX_ERROR;
16711671
}
16721672
ngx_log_debug2(NGX_LOG_DEBUG_CORE, log, 0, "geteuid now %ud:%ud", geteuid(), getegid());
1673-
}else if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT) {
1674-
pw = getpwuid (ouid);
1675-
username = pw->pw_name;
16761673
}
1677-
1674+
16781675
for (i = 0; i < mcf->jvm_cp->nelts; i++) {
1679-
ngx_log_debug2(NGX_LOG_DEBUG_CORE, log, 0, "checking %V, nginx user:%s", &elts[i], username);
1676+
ngx_log_debug2(NGX_LOG_DEBUG_CORE, log, 0, "checking %V, nginx user with id : %ud ", &elts[i], ouid);
16801677
if (ngx_http_clojure_faccessat((char *)elts[i].data, log) != 0) {
16811678
err = ngx_errno;
1682-
ngx_log_error(NGX_LOG_EMERG, log, err, "check access jvm classpath file \"%V\" failed by os user \"%s\"", &elts[i], username);
1679+
ngx_log_error(NGX_LOG_EMERG, log, err, "check access jvm classpath file \"%V\" failed by os user with id \"%ud\"", &elts[i], ouid);
16831680
rc = NGX_ERROR;
16841681

16851682
if (err == EACCES) {
16861683
ngx_log_error(NGX_LOG_EMERG, log, 0,
1687-
"it is caused by os user \"%s\" has no direct access permission, "
1684+
"it is caused by os user with id \"%ud\" has no direct access permission, "
16881685
"or search permission (viz. x-permission for a directory) is denied "
1689-
"for one of the directories in the path prefix of pathname", username);
1686+
"for one of the directories in the path prefix of pathname", ouid);
16901687
}
16911688
break;
16921689
}

0 commit comments

Comments
 (0)