Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ownership of dirs in /var/cache/boomaga #120

Open
coldcoff opened this issue Nov 29, 2022 · 0 comments
Open

ownership of dirs in /var/cache/boomaga #120

coldcoff opened this issue Nov 29, 2022 · 0 comments

Comments

@coldcoff
Copy link

I needed the following patch to make it run:

diff --git a/src/backend/cups_backend/main.cpp b/src/backend/cups_backend/main.cpp
index b0973d0..44bb236 100644
--- a/src/backend/cups_backend/main.cpp
+++ b/src/backend/cups_backend/main.cpp
@@ -63,6 +63,20 @@ static int getmod(const string &file)
     return 0;
 }
 
+/************************************************
+ *
+ ************************************************/
+static uid_t getown(const string &file)
+{
+    struct stat fstat;
+    if (stat(file.c_str(), &fstat) == 0)
+    {
+        return fstat.st_uid;
+    }
+
+    return 0;
+}
+
 
 /************************************************
  *
@@ -113,13 +127,13 @@ static string mkUserDir(const string &baseDir, const string &user)
         return "";
     }
 
-    if (chown(dir.c_str(), pwd->pw_uid, -1) != 0)
+    if (getown(dir) != pwd->pw_uid && chown(dir.c_str(), pwd->pw_uid, -1) != 0)
     {
         Log::error("Can't change owner on directory %s: %s", dir.c_str(), std::strerror(errno));
         return "";
     }
 
-    Log::debug("User directory %s saccefully created", dir.c_str());
+    Log::debug("User directory %s succesfully created", dir.c_str());
     return dir;
 }
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant