-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In the Snap patch PAPPL to allow normal-user clients access the Snap'…
…s server The server run by the Snap runs as root, as a Snap is installed into the system, not into the user's home directory and so a process started by the Snap installation must be a system process and that is why Snaps run daemons as root. Running the Printer Application as a client (from the command line) it runs as the calling user and PAPPL does not associate it with the system-wide server which the Snap has started as root. PAPPL always creates the socket file with the user ID in the file name, so the call as client uses its own socket file name, does not find the Snap's server and fires up its own server. See michaelrsweet/pappl#148 When building the Snap we are patching PAPPL now in a way that if a client does not find a server uder the user's socket name, it tries root's socket name (the system-wide server of the Snap in our case), and only if this also fails it fires up its own server.
- Loading branch information
1 parent
c772ea0
commit 8bb880b
Showing
2 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
diff --git a/pappl/mainloop-private.h b/pappl/mainloop-private.h | ||
index 5af4695..9bde73a 100644 | ||
--- a/pappl/mainloop-private.h | ||
+++ b/pappl/mainloop-private.h | ||
@@ -59,7 +59,7 @@ extern void _papplMainloopAddPrinterURI(ipp_t *request, const char *printer_name | ||
extern http_t *_papplMainloopConnect(const char *base_name, bool auto_start) _PAPPL_PRIVATE; | ||
extern http_t *_papplMainloopConnectURI(const char *base_name, const char *printer_uri, char *resource, size_t rsize) _PAPPL_PRIVATE; | ||
extern char *_papplMainloopGetDefaultPrinter(http_t *http, char *buffer, size_t bufsize) _PAPPL_PRIVATE; | ||
-extern char *_papplMainloopGetServerPath(const char *base_name, char *buffer, size_t bufsize) _PAPPL_PRIVATE; | ||
+ extern char *_papplMainloopGetServerPath(const char *base_name, bool system_wide, char *buffer, size_t bufsize) _PAPPL_PRIVATE; | ||
|
||
|
||
// | ||
diff --git a/pappl/mainloop-subcommands.c b/pappl/mainloop-subcommands.c | ||
index a572d6e..a79ac03 100644 | ||
--- a/pappl/mainloop-subcommands.c | ||
+++ b/pappl/mainloop-subcommands.c | ||
@@ -605,7 +605,7 @@ _papplMainloopRunServer( | ||
papplSystemSetPrinterDrivers(system, num_drivers, drivers, autoadd_cb, /* create_cb */NULL, driver_cb, data); | ||
|
||
// Listen for connections... | ||
- papplSystemAddListeners(system, _papplMainloopGetServerPath(base_name, sockname, sizeof(sockname))); | ||
+ papplSystemAddListeners(system, _papplMainloopGetServerPath(base_name, false, sockname, sizeof(sockname))); | ||
|
||
// Finish initialization... | ||
if (!system->save_cb) | ||
diff --git a/pappl/mainloop-support.c b/pappl/mainloop-support.c | ||
index e54f438..deb5d94 100644 | ||
--- a/pappl/mainloop-support.c | ||
+++ b/pappl/mainloop-support.c | ||
@@ -316,8 +316,12 @@ _papplMainloopConnect( | ||
char sockname[1024]; // Socket filename | ||
|
||
|
||
- // See if the server is running... | ||
- http = httpConnect2(_papplMainloopGetServerPath(base_name, sockname, sizeof(sockname)), 0, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL); | ||
+ // See if a user server is running... | ||
+ http = httpConnect2(_papplMainloopGetServerPath(base_name, false, sockname, sizeof(sockname)), 0, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL); | ||
+ | ||
+ // See if there is a system-wide server | ||
+ if (!http) | ||
+ http = httpConnect2(_papplMainloopGetServerPath(base_name, true, sockname, sizeof(sockname)), 0, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL); | ||
|
||
if (!http && auto_start) | ||
{ | ||
@@ -333,6 +337,8 @@ _papplMainloopConnect( | ||
NULL | ||
}; | ||
|
||
+ _papplMainloopGetServerPath(base_name, false, sockname, sizeof(sockname)); | ||
+ | ||
posix_spawnattr_init(&server_attrs); | ||
posix_spawnattr_setpgroup(&server_attrs, 0); | ||
|
||
@@ -449,6 +455,7 @@ _papplMainloopGetDefaultPrinter( | ||
char * // O - Socket filename | ||
_papplMainloopGetServerPath( | ||
const char *base_name, // I - Base name | ||
+ bool system_wide, // I - System-wide server | ||
char *buffer, // I - Buffer for filename | ||
size_t bufsize) // I - Size of buffer | ||
{ | ||
@@ -463,7 +470,7 @@ _papplMainloopGetServerPath( | ||
tmpdir = "/tmp"; | ||
#endif // __APPLE__ | ||
|
||
- snprintf(buffer, bufsize, "%s/%s%d.sock", tmpdir, base_name, (int)getuid()); | ||
+ snprintf(buffer, bufsize, "%s/%s%d.sock", tmpdir, base_name, (system_wide ? 0 : (int)getuid())); | ||
_PAPPL_DEBUG("Creating domain socket as '%s'.\n", buffer); | ||
|
||
return (buffer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters