Date: Thu, 14 May 1998 19:31:22 -0500 (CDT) From: doogie@forbidden-donut.anet-stl.com To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/6636: There is no way to set real/idletime priority in login.conf Message-ID: <19980515003122.1C21F043DA@forbidden-donut.anet-stl.com>
next in thread | raw e-mail | index | archive | help
>Number: 6636 >Category: bin >Synopsis: There is no way to set real/idletime priority in login.conf >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu May 14 17:30:00 PDT 1998 >Last-Modified: >Originator: Jason Young >Organization: ANET St. Louis >Release: FreeBSD 2.2.6-STABLE i386 >Environment: FreeBSD 3.0-CURRENT, as of 05-10-98 FreeBSD 2.2.6-STABLE, as of 05-10-98 >Description: There is no way to set idle or realtime processing priorities for an entire user class via the login.conf file. This capability is highly desirable. For example, you might wish to set all normal shell users to an idletime processing class, to keep them from being able to interfere with system processes. You might also set root logins at the console to a realtime value, so that you can get into a machine that's running something out of control. This is only what I can think of off the top of my head. >How-To-Repeat: N/A. >Fix: This patch adapts the 'priority' attribute to understand values ranging from 52 to -52, to allow setting of priority in a manner identical to that displayed by top(1). 21-52 are idletime priorities, -21 to -52 are realtime, and 20 to -20 are normal nice values. *** login_class.c.old Sat May 10 13:55:38 1997 --- login_class.c Sun May 10 07:08:07 1998 *************** *** 36,45 **** --- 36,46 ---- #include <fcntl.h> #include <pwd.h> #include <syslog.h> #include <login_cap.h> #include <paths.h> + #include <sys/rtprio.h> #undef UNKNOWN #define UNKNOWN "su" *************** *** 313,322 **** --- 314,324 ---- setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned int flags) { quad_t p; mode_t mymask; login_cap_t *llc = NULL; + struct rtprio rtp; if (lc == NULL) { if (pwd != NULL && (lc = login_getpwclass(pwd)) != NULL) llc = lc; /* free this when we're done */ } *************** *** 328,343 **** if (pwd == NULL) flags &= ~(LOGIN_SETGROUP | LOGIN_SETLOGIN); /* Set the process priority */ if (flags & LOGIN_SETPRIORITY) { ! p = login_getcapnum(lc, "priority", LOGIN_DEFPRI, LOGIN_DEFPRI); ! p = (p < PRIO_MIN || p > PRIO_MAX) ? LOGIN_DEFPRI : p; ! if (setpriority(PRIO_PROCESS, 0, (int)p) != 0) ! syslog(LOG_WARNING, "setpriority '%s' (%s): %m", pwd->pw_name, lc ? lc->lc_class : LOGIN_DEFCLASS); } /* Setup the user's group permissions */ if (flags & LOGIN_SETGROUP) { if (setgid(pwd->pw_gid) != 0) { --- 330,360 ---- if (pwd == NULL) flags &= ~(LOGIN_SETGROUP | LOGIN_SETLOGIN); /* Set the process priority */ if (flags & LOGIN_SETPRIORITY) { ! p = login_getcapnum(lc, "priority", LOGIN_DEFPRI, LOGIN_DEFPRI); ! if(p > PRIO_MAX) { ! rtp.type = RTP_PRIO_IDLE; ! rtp.prio = p - PRIO_MAX - 1; ! p = (rtp.prio > RTP_PRIO_MAX) ? 31 : p; ! if(rtprio(RTP_SET, 0, &rtp)) ! syslog(LOG_WARNING, "rtprio '%s' (%s): %m", pwd->pw_name, lc ? lc->lc_class : LOGIN_DEFCLASS); + } else if(p < PRIO_MIN) { + rtp.type = RTP_PRIO_REALTIME; + rtp.prio = abs(p - PRIO_MIN + RTP_PRIO_MAX); + p = (rtp.prio > RTP_PRIO_MAX) ? 1 : p; + if(rtprio(RTP_SET, 0, &rtp)) + syslog(LOG_WARNING, "rtprio '%s' (%s): %m", + pwd->pw_name, lc ? lc->lc_class : LOGIN_DEFCLASS); + } else { + if (setpriority(PRIO_PROCESS, 0, (int)p) != 0) + syslog(LOG_WARNING, "setpriority '%s' (%s): %m", + pwd->pw_name, lc ? lc->lc_class : LOGIN_DEFCLASS); + } } /* Setup the user's group permissions */ if (flags & LOGIN_SETGROUP) { if (setgid(pwd->pw_gid) != 0) { >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980515003122.1C21F043DA>