]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Allow Solaris privileges to work on both Solaris and derivatives
authorSpencer Thomason <spencer@whiteskycommunications.com>
Thu, 28 Jan 2016 03:54:47 +0000 (19:54 -0800)
committerSpencer Thomason <spencer@whiteskycommunications.com>
Thu, 28 Jan 2016 03:54:47 +0000 (19:54 -0800)
Solaris does not have PRIV_PROC_PRIOUP but SmartOS does.  This allows
fallback to this privilege on supported platforms

FS-8195 #resolve

src/switch_core.c

index 2d342fb33b026ea0b98e32ccb03c9e5fd900f2da..259807a2876fc07ad63ca6f84cb9f03deafc3474 100644 (file)
@@ -982,24 +982,30 @@ SWITCH_DECLARE(int32_t) set_realtime_priority(void)
 #ifdef SOLARIS_PRIVILEGES
        /* request the privileges to elevate the priority */
        if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_PRIOCNTL, NULL) < 0) {
+#ifdef PRIV_PROC_PRIOUP
+               /* fallback to PRIV_PROC_PRIOUP on SmartOS */
                fprintf(stderr, "WARN: Failed to acquire proc_priocntl privilege (%s)\n", strerror(errno));
-       } else {
-               if (sched_setscheduler(0, SCHED_FIFO, &sched) < 0) {
-                       fprintf(stderr, "ERROR: Failed to set SCHED_FIFO scheduler (%s)\n", strerror(errno));
-               } else {
-                       return 0;
+               if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_PRIOUP, NULL) < 0) {
+                       fprintf(stderr, "ERROR: Failed to acquire proc_prioup privilege (%s)\n", strerror(errno));
+                       return -1;
                }
-       }
-               
-       if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_PRIOUP, NULL) < 0) {
-               fprintf(stderr, "ERROR: Failed to acquire proc_prioup privilege (%s)\n", strerror(errno));
+#else
+               fprintf(stderr, "ERROR: Failed to acquire proc_priocntl privilege (%s)\n", strerror(errno));
                return -1;
+#endif
+       }
+
+       if (sched_setscheduler(0, SCHED_FIFO, &sched) < 0) {
+               fprintf(stderr, "WARN: Failed to set SCHED_FIFO scheduler (%s)\n", strerror(errno));
        } else {
-               if (setpriority(PRIO_PROCESS, 0, -10) < 0) {
-                       fprintf(stderr, "ERROR: Could not set nice level\n");
-                       return -1;
-               }
+               return 0;
        }
+
+       if (setpriority(PRIO_PROCESS, 0, -10) < 0) {
+               fprintf(stderr, "ERROR: Could not set nice level\n");
+               return -1;
+       }
+
        return 0;
 #else