Add artswrapper, a suid wrapper for aRts.
This commit is contained in:
parent
b22140d86d
commit
6bc6beb3e8
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=103387
4 changed files with 150 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
||||||
SUBDIR += amp
|
SUBDIR += amp
|
||||||
SUBDIR += ample
|
SUBDIR += ample
|
||||||
SUBDIR += arts
|
SUBDIR += arts
|
||||||
|
SUBDIR += artswrapper
|
||||||
SUBDIR += ascd
|
SUBDIR += ascd
|
||||||
SUBDIR += asmix
|
SUBDIR += asmix
|
||||||
SUBDIR += asmixer
|
SUBDIR += asmixer
|
||||||
|
|
32
audio/artswrapper/Makefile
Normal file
32
audio/artswrapper/Makefile
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# New ports collection makefile for: artsrapper
|
||||||
|
# Date created: 2004-03-04
|
||||||
|
# Whom: Michael Nottebrock <lofi@freebsd.org>
|
||||||
|
#
|
||||||
|
# $FreeBSD$
|
||||||
|
#
|
||||||
|
|
||||||
|
PORTNAME= artswrapper
|
||||||
|
PORTVERSION= 1.2.1
|
||||||
|
CATEGORIES= audio
|
||||||
|
DISTNAME= # none
|
||||||
|
EXTRACT_SUFX= # none
|
||||||
|
|
||||||
|
MAINTAINER= kde@freebsd.org
|
||||||
|
COMMENT= Setuid wrapper for arts
|
||||||
|
|
||||||
|
IGNORE= This port is part of KDE 3.2.1 and is not yet ready
|
||||||
|
|
||||||
|
NO_WRKSUBDIR= yes
|
||||||
|
PLIST_FILES= bin/artswrapper
|
||||||
|
|
||||||
|
do-fetch:
|
||||||
|
|
||||||
|
.include <bsd.port.pre.mk>
|
||||||
|
|
||||||
|
do-build:
|
||||||
|
${CC} ${CFLAGS} -DHAVE_REALTIME_SCHED -DEXECUTE=\"${LOCALBASE}/bin/artsd\" -o ${WRKSRC}/artswrapper ${FILESDIR}/artswrapper.c
|
||||||
|
|
||||||
|
do-install:
|
||||||
|
${INSTALL} ${COPY} ${STRIP} ${_BINOWNGRP} -m 4555 ${WRKSRC}/artswrapper ${PREFIX}/bin
|
||||||
|
|
||||||
|
.include <bsd.port.post.mk>
|
114
audio/artswrapper/files/artswrapper.c
Normal file
114
audio/artswrapper/files/artswrapper.c
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* adjust_priority
|
||||||
|
*
|
||||||
|
* sets realtime priority
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_REALTIME_SCHED
|
||||||
|
#include <sched.h>
|
||||||
|
|
||||||
|
void adjust_priority()
|
||||||
|
{
|
||||||
|
int sched = sched_getscheduler(0);
|
||||||
|
if(sched == SCHED_FIFO || sched == SCHED_RR)
|
||||||
|
{
|
||||||
|
printf(">> since the scheduling policy is not standard, I assume\n");
|
||||||
|
printf(" it has been adjusted to fit the needs of realtime audio\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct sched_param sp;
|
||||||
|
long priority = (sched_get_priority_max(SCHED_FIFO) +
|
||||||
|
sched_get_priority_min(SCHED_FIFO))/2;
|
||||||
|
|
||||||
|
sp.sched_priority = priority;
|
||||||
|
|
||||||
|
if(sched_setscheduler(0, SCHED_FIFO, &sp) != -1)
|
||||||
|
{
|
||||||
|
printf(">> running as realtime process now (priority %ld)\n",
|
||||||
|
priority);
|
||||||
|
putenv("STARTED_THROUGH_ARTSWRAPPER=1");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* can't set realtime priority */
|
||||||
|
putenv("STARTED_THROUGH_ARTSWRAPPER=2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void adjust_priority()
|
||||||
|
{
|
||||||
|
int prio;
|
||||||
|
|
||||||
|
prio = getpriority(PRIO_PROCESS,getpid());
|
||||||
|
if(prio > -10)
|
||||||
|
{
|
||||||
|
setpriority(PRIO_PROCESS,getpid(),-17);
|
||||||
|
prio = getpriority(PRIO_PROCESS,getpid());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* no system support for realtime priority */
|
||||||
|
putenv("STARTED_THROUGH_ARTSWRAPPER=3");
|
||||||
|
|
||||||
|
if(prio > -10) {
|
||||||
|
printf(">> synthesizer priority is %d (which is unacceptable,",prio);
|
||||||
|
printf(" try running as root)\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf(">> synthesizer priority is %d (which is the best\n",prio);
|
||||||
|
printf(" we can get out of a non realtime system)\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if(argc == 2)
|
||||||
|
{
|
||||||
|
if(strcmp(argv[1],"check") == 0)
|
||||||
|
{
|
||||||
|
/* backward compatibility with old artswrapper */
|
||||||
|
printf("okay\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
adjust_priority();
|
||||||
|
|
||||||
|
/* drop root privileges if running setuid root
|
||||||
|
(due to realtime priority stuff) */
|
||||||
|
if (geteuid() != getuid())
|
||||||
|
{
|
||||||
|
#if defined (HAVE_SETEUID) && !defined (HAVE_SETEUID_FAKE)
|
||||||
|
seteuid(getuid());
|
||||||
|
#else
|
||||||
|
setreuid(-1, getuid());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if(argc == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Real-time status is passed to artsd via the environment variable
|
||||||
|
* STARTED_THROUGH_ARTSWRAPPER. It has one of the following values:
|
||||||
|
*
|
||||||
|
* unset - not running as real-time
|
||||||
|
* 1 - running as real-time
|
||||||
|
* 2 - no privileges to set real-time scheduling
|
||||||
|
* 3 - no support for real-time scheduling
|
||||||
|
*/
|
||||||
|
argv[0] = EXECUTE;
|
||||||
|
execv(EXECUTE,argv);
|
||||||
|
perror(EXECUTE);
|
||||||
|
return 1;
|
||||||
|
}
|
3
audio/artswrapper/pkg-descr
Normal file
3
audio/artswrapper/pkg-descr
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
This program launches artsd (from the audio/arts port), optionally with
|
||||||
|
elevated priority. To do this, it needs superuser priviliges and is installed
|
||||||
|
setuid root.
|
Loading…
Reference in a new issue