]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
hfaxd: Move JobProtection to be default file permissions for sendq/doneq files
authorAidan Van Dyk <aidan@ifax.com>
Mon, 22 Sep 2008 19:43:18 +0000 (19:43 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Mon, 22 Sep 2008 19:43:18 +0000 (19:43 +0000)
This allows us to give finer control users some day of how (and how) others can
see the job.

For now, it allows us to use a unified mechanism for HylaFAX access control
based on filesystem mode and gid.

hfaxd/HylaFAXServer.c++
hfaxd/Jobs.c++
man/hfaxd.1m

index 417dca5007982516ef14ff0260350f23209cd9b2..b868664092308f8bfdb2c1de9c59595642f5de88 100644 (file)
@@ -608,6 +608,10 @@ HylaFAXServer::resetConfig()
 
 #define        N(a)    (sizeof (a) / sizeof (a[0]))
 
+/*
+ * logFacility *must* be tie first entry - see it's handling
+ * below in setConfigItem()
+ */
 HylaFAXServer::stringtag HylaFAXServer::strings[] = {
 { "logfacility",       &HylaFAXServer::logFacility,    LOG_FAX },
 { "faxcontact",                &HylaFAXServer::faxContact,     "FaxMaster" },
@@ -630,7 +634,12 @@ HylaFAXServer::stringtag HylaFAXServer::strings[] = {
   "UNIX Type: L8 Version: SVR4" },
 { "admingroup",                &HylaFAXServer::admingroup },
 };
+
+/*
+ * jobprotection needs to be first as well, see setConfigItem() below
+ */
 HylaFAXServer::numbertag HylaFAXServer::numbers[] = {
+{ "jobprotection",     &HylaFAXServer::jobProtection,          0644 },
 { "servertracing",     &HylaFAXServer::tracingLevel,           TRACE_SERVER },
 { "idletimeout",       &HylaFAXServer::idleTimeout,            900 },
 { "maxidletimeout",    &HylaFAXServer::maxIdleTimeout,         7200 },
@@ -639,7 +648,6 @@ HylaFAXServer::numbertag HylaFAXServer::numbers[] = {
 { "maxloginattempts",  &HylaFAXServer::maxLoginAttempts,       5 },
 { "maxadminattempts",  &HylaFAXServer::maxAdminAttempts,       5 },
 { "maxconsecutivebadcmds",&HylaFAXServer::maxConsecutiveBadCmds,10 },
-{ "jobprotection",     &HylaFAXServer::jobProtection,          0444 },
 };
 HylaFAXServer::booltag HylaFAXServer::booleans[] = {
 { "allowsorting",      &HylaFAXServer::allowSorting,           true },
@@ -691,6 +699,13 @@ HylaFAXServer::setConfigItem(const char* tag, const char* value)
        }
     } else if (findTag(tag, (const tags*) numbers, N(numbers), ix)) {
        (*this).*numbers[ix].p = getNumber(value);
+       switch (ix) {
+       case 0: if ( (jobProtection & 0600) != 0600)
+           {
+               logError("JobProtection value must include 0600, forcing");
+               jobProtection |= 0600;
+           }
+       }
     } else if (findTag(tag, (const tags*) booleans, N(booleans), ix)) {
        (*this).*booleans[ix].p = getBoolean(value);
     } else
index 5391b3b239db5a043713687ae590005ccefff7ef..aad321424884b9767f1babd5089863341e008b64 100644 (file)
@@ -923,7 +923,7 @@ HylaFAXServer::newJobCmd(void)
     if (newJob(emsg) && updateJobOnDisk(*curJob, emsg)) {
        fxStr file("/" | curJob->qfile);
        setFileOwner(file);                     // force ownership
-       FileCache::chmod(file, 0660);           // sync cache
+       FileCache::chmod(file, jobProtection);  // sync cache
        curJob->lastmod = Sys::now();           // noone else should update
        reply(200, "New job created: jobid: %s groupid: %s.",
            (const char*) curJob->jobid, (const char*) curJob->groupid);
@@ -1015,7 +1015,7 @@ HylaFAXServer::updateJobOnDisk(Job& job, fxStr& emsg)
 {
     if (job.fd < 0)
     {
-       job.fd = Sys::open("/" | job.qfile, O_RDWR|O_CREAT, 0600);
+       job.fd = Sys::open("/" | job.qfile, O_RDWR|O_CREAT, jobProtection);
        if (job.fd < 0)
        {
            emsg = "Cannot open/create job description file /" | job.qfile;
index 9a66e69a6cdc8b6b255b64921f02f54782fc3307..a702f3a617cee1a8bd39a09a0e2744879a305e5f 100644 (file)
@@ -391,7 +391,7 @@ FileSortFmt string  \s-1-\s+1       format string for sorting file status listing
 IdleTimeout    integer \s-1900\s+1     client idle timeout in seconds
 JobFmt string  \s-1\fIsee below\fP\s+1 format string for job status results
 JobSortFmt     string  \s-1-\s+1       format string for sorting job status listing
-JobProtection  octal   \s-10444\s+1    permissions for client access to jobs
+JobProtection  octal   \s-10444\s+1    permissions for job qfiles in sendq/docq
 KillTimeMap    string  \s-1\fIsee below\fP\s+1 mapping from service level to job kill time (\s-1SNPP\s+1)
 LogFacility    string  \s-1daemon\s+1  \fIsyslog\fP facility name for tracing messages
 MaxAdminAttempts       integer \s-15\s+1       maximum admin attempts before disconnecting
@@ -562,14 +562,11 @@ The format string to use when sorting the listing for jobs in the
 sendq and doneq directories.  Follows the JobFmt formatting rules.
 .TP 10
 .B JobProtection
-The permissions setting for viewing jobs in the \*(Fx queues.  The
-default setting of ``0444'' allows all users to view all jobs in the send/done
-queues.  The permissions copy unix filesystem permission, with the 3 sets
-being owner, admin, and others, instead of owner/group/other.  The only
-permissions that are meaningful are read, because write permissions are
-controlled for the specific properties of the job.  If a user doesn't have
-read permissions on the job, the job will not be visible to them.  Useful
-settings are ``0444'' (for oao=r), ``0440'' (for oa=r), and ``0400'' (for o=r).
+The file mode setting for job qfiles in the \*(Fx queues (sendq and doneq).
+The default setting of ``0644'' allows all users to view all job paramaters in
+the send/done queues.   The mode determines the permissions of the clients to
+see the jobs, following the \*(Fx permission model of the group bits
+controlling uid permissions and the other bits controlling other permissions.
 .TP 10
 .B KillTimeMap
 The mapping from \s-1SNPP\s+1 service level (0-11) to job expiration time