Skip to content

Commit

Permalink
NavWindow: fix file permissions bug
Browse files Browse the repository at this point in the history
NavWindow: fix file permissions bug

NavWindow: fix folder permissions bug

renaming promises
  • Loading branch information
ahmedr2001 committed Apr 12, 2023
1 parent cf7910c commit 9546d46
Showing 1 changed file with 36 additions and 12 deletions.
48 changes: 36 additions & 12 deletions navigator/components/NavWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ export class NavWindow {
}

async mkdir() {
let current_user;
var user_promise = cockpit.user();
user_promise.then(user => current_user = user.name);
let response = await this.modal_prompt.prompt("Creating Directory",
{
new_name: {
Expand All @@ -518,15 +521,24 @@ export class NavWindow {
return;
}
var promise = new Promise((resolve, reject) => {
var proc = cockpit.spawn(
["mkdir", this.pwd().path_str() + "/" + new_dir_name],
{superuser: "try", err: "out"}
var admin_access_proc = cockpit.spawn(
["runuser", "-u", current_user, "mkdir", this.pwd().path_str() + "/" + new_dir_name],
{superuser: "require", err: "out"}
);
proc.done((data) => {
admin_access_proc.done((data) => {
resolve();
});
proc.fail((e, data) => {
reject(data);
admin_access_proc.fail((e, data) => {
var limited_access_proc = cockpit.spawn(
["mkdir", this.pwd().path_str() + "/" + new_dir_name],
{superuser: "try", err: "out"}
);
limited_access_proc.done((data) => {
resolve();
});
limited_access_proc.fail((e, data) => {
reject(data);
})
});
});
try {
Expand All @@ -538,6 +550,9 @@ export class NavWindow {
}

async touch() {
let current_user;
var user_promise = cockpit.user();
user_promise.then(user => current_user = user.name);
let response = await this.modal_prompt.prompt("Creating File",
{
new_name: {
Expand All @@ -558,15 +573,24 @@ export class NavWindow {
return;
}
var promise = new Promise((resolve, reject) => {
var proc = cockpit.spawn(
["/usr/share/cockpit/navigator/scripts/touch.py3", this.pwd().path_str() + "/" + new_file_name],
{superuser: "try", err: "out"}
var admin_access_proc = cockpit.spawn(
["runuser", "-u", current_user, "/usr/share/cockpit/navigator/scripts/touch.py3", this.pwd().path_str() + "/" + new_file_name],
{superuser: "require", err: "out"}
);
proc.done((data) => {
admin_access_proc.done((data) => {
resolve();
});
proc.fail((e, data) => {
reject(data);
admin_access_proc.fail((e, data) => {
var limited_access_proc = cockpit.spawn(
["/usr/share/cockpit/navigator/scripts/touch.py3", this.pwd().path_str() + "/" + new_file_name],
{superuser: "try", err: "out"}
);
limited_access_proc.done((data) => {
resolve();
});
limited_access_proc.fail((e, data) => {
reject(data);
})
});
});
try {
Expand Down

0 comments on commit 9546d46

Please sign in to comment.