Skip to content

Commit

Permalink
daemon: add debugging logs to trusted user logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo committed Jan 9, 2024
1 parent 711a732 commit 608ce1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7992,10 +7992,15 @@ function getUserConfigDirs() {
async function isTrustedUser() {
try {
let user = os.userInfo().username;
core.debug(`Checking if user ${user} is trusted`);
let userGroups = await execToVariable('id', ['-Gn', user], { silent: true }).then((str) => str.trim().split(' '));
core.debug(`User ${user} is in groups ${userGroups}`);
let [trustedUsers, trustedGroups] = await fetchTrustedUsers().then(partitionUsersAndGroups);
core.debug(`Trusted users: ${trustedUsers}`);
core.debug(`Trusted groups: ${trustedGroups}`);
// Chech if Nix is installed in single-user mode.
let isStoreWritable = isWritable('/nix/store');
core.debug(`Is store writable: ${isStoreWritable}`);
return isStoreWritable
|| trustedUsers.includes(user)
|| trustedGroups.some((group) => userGroups.includes(group));
Expand Down
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,17 @@ function getUserConfigDirs(): string[] {
async function isTrustedUser(): Promise<boolean> {
try {
let user = os.userInfo().username;
core.debug(`Checking if user ${user} is trusted`);
let userGroups = await execToVariable('id', ['-Gn', user], { silent: true }).then((str) => str.trim().split(' '));
core.debug(`User ${user} is in groups ${userGroups}`);

let [trustedUsers, trustedGroups] = await fetchTrustedUsers().then(partitionUsersAndGroups);
core.debug(`Trusted users: ${trustedUsers}`);
core.debug(`Trusted groups: ${trustedGroups}`);

// Chech if Nix is installed in single-user mode.
let isStoreWritable = isWritable('/nix/store');
core.debug(`Is store writable: ${isStoreWritable}`);

return isStoreWritable
|| trustedUsers.includes(user)
Expand Down

0 comments on commit 608ce1e

Please sign in to comment.