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
  • Loading branch information
ahmedr2001 committed Apr 12, 2023
1 parent cf7910c commit 24df606
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 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 @@ -519,14 +522,23 @@ export class NavWindow {
}
var promise = new Promise((resolve, reject) => {
var proc = cockpit.spawn(
["mkdir", this.pwd().path_str() + "/" + new_dir_name],
{superuser: "try", err: "out"}
["runuser", "-u", current_user, "mkdir", this.pwd().path_str() + "/" + new_dir_name],
{superuser: "require", err: "out"}
);
proc.done((data) => {
resolve();
});
proc.fail((e, data) => {
reject(data);
var proc2 = cockpit.spawn(
["mkdir", this.pwd().path_str() + "/" + new_dir_name],
{superuser: "try", err: "out"}
);
proc2.done((data) => {
resolve();
});
proc2.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 @@ -559,14 +574,23 @@ export class NavWindow {
}
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"}
["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) => {
resolve();
});
proc.fail((e, data) => {
reject(data);
var proc2 = cockpit.spawn(
["/usr/share/cockpit/navigator/scripts/touch.py3", this.pwd().path_str() + "/" + new_file_name],
{superuser: "try", err: "out"}
);
proc2.done((data) => {
resolve();
});
proc2.fail((e, data) => {
reject(data);
})
});
});
try {
Expand Down

0 comments on commit 24df606

Please sign in to comment.