- Update to 4.13
PR: 129632 Submitted by: Alex Samorukov <samm@os2.kiev.ua>
This commit is contained in:
parent
1fa2c0cb6a
commit
4433a66a8d
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=224251
6 changed files with 17 additions and 707 deletions
|
@ -6,14 +6,13 @@
|
|||
#
|
||||
|
||||
PORTNAME= anyremote
|
||||
PORTVERSION= 4.11
|
||||
PORTVERSION= 4.13
|
||||
CATEGORIES= comms
|
||||
MASTER_SITES= SF
|
||||
|
||||
MAINTAINER= samm@os2.kiev.ua
|
||||
COMMENT= Remote control service over Bluetooth,infrared or tcp/ip networking
|
||||
|
||||
USE_AUTOTOOLS= automake:14 autoconf:262 libtool:15
|
||||
GNU_CONFIGURE= yes
|
||||
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
|
||||
LDFLAGS="-L${LOCALBASE}/lib"
|
||||
|
@ -31,11 +30,9 @@ MAKE_ARGS+= LDFLAGS="-L${LOCALBASE}/lib"
|
|||
MAN1= anyremote.1
|
||||
MANCOMPRESSED= yes
|
||||
|
||||
pre-configure:
|
||||
cd ${WRKSRC} && ${AUTOMAKE} -a && ${AUTORECONF}
|
||||
pre-build:
|
||||
cd ${WRKSRC} && ${MAKE} clean
|
||||
post-patch:
|
||||
@${REINPLACE_CMD} -e 's|(datadir)/man/man1|(mandir)/man1|g' ${WRKSRC}/Makefile.am
|
||||
@${REINPLACE_CMD} -e 's|(datadir)/man/man1|(mandir)/man1|g' ${WRKSRC}/Makefile.in
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
MD5 (anyremote-4.11.tar.gz) = b4a856b3f95de57ce1c227c0f43eb0dd
|
||||
SHA256 (anyremote-4.11.tar.gz) = d0e411d1afacecd0f6732ed5454989434a039f172b599cbaaaacec783cfc63a8
|
||||
SIZE (anyremote-4.11.tar.gz) = 1457711
|
||||
MD5 (anyremote-4.13.tar.gz) = 38abc204b729ef552ed6d20f12edda4e
|
||||
SHA256 (anyremote-4.13.tar.gz) = 92f1b73c751c09b179baec496476024fec1207e0081a42fb06df22f6e6e53ff1
|
||||
SIZE (anyremote-4.13.tar.gz) = 1294625
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- Makefile.am 2008-10-16 21:00:58.000000000 +0200
|
||||
+++ Makefile.am 2008-11-05 12:23:19.000000000 +0100
|
||||
@@ -24,12 +24,8 @@
|
||||
--- Makefile.in.orig 2008-12-14 14:55:09.000000000 +0200
|
||||
+++ Makefile.in 2008-12-14 14:56:00.000000000 +0200
|
||||
@@ -609,12 +609,8 @@
|
||||
|
||||
install-data-local:
|
||||
test -z $(DESTDIR)$(pkgdatadir) || mkdir -p -- . $(DESTDIR)$(pkgdatadir)
|
||||
|
|
|
@ -1,486 +0,0 @@
|
|||
diff -ur configure.in anyremote-4.11-fbsd/configure.in
|
||||
--- configure.in 2008-10-16 20:56:17.000000000 +0200
|
||||
+++ configure.in 2008-10-31 13:09:34.000000000 +0100
|
||||
@@ -53,14 +53,31 @@
|
||||
#AC_CONFIG_FILES([Makefile
|
||||
# src/Makefile])
|
||||
|
||||
-AC_ARG_ENABLE(bluez,
|
||||
- [ --disable-bluez disable bluez support])
|
||||
+AC_CANONICAL_HOST
|
||||
|
||||
-if test x"$enable_bluez" != xno; then
|
||||
- AC_CHECK_HEADERS([bluetooth/bluetooth.h], [], [echo "Can not find bluetooth.h ! Install it or use --disable-bluez";exit])
|
||||
- AR_EXTRAFLAGS="$AR_EXTRAFLAGS -DUSE_BT=1"
|
||||
- AR_EXTRALIBS="$AR_EXTRALIBS -lbluetooth"
|
||||
-fi
|
||||
+case "$host_os" in
|
||||
+linux*)
|
||||
+ AC_ARG_ENABLE(bluez,
|
||||
+ [ --disable-bluez disable bluez support])
|
||||
+
|
||||
+ if test x"$enable_bluez" != xno; then
|
||||
+ AC_CHECK_HEADERS([bluetooth/bluetooth.h], [], [echo "Can not find bluetooth.h ! Install it or use --disable-bluez";exit])
|
||||
+ AR_EXTRAFLAGS="$AR_EXTRAFLAGS -DUSE_BT=1"
|
||||
+ AR_EXTRALIBS="$AR_EXTRALIBS -lbluetooth"
|
||||
+ fi
|
||||
+ AR_EXTRAFLAGS="$AR_EXTRAFLAGS -DHAVE_GETLINE=1"
|
||||
+ ;;
|
||||
+freebsd*)
|
||||
+ AC_ARG_ENABLE(bluetooth,
|
||||
+ [ --disable-bluetooth disable bluetooth support])
|
||||
+
|
||||
+ if test x"$enable_bluetooth" != xno; then
|
||||
+ AC_CHECK_HEADERS([bluetooth.h], [], [echo "Can not find bluetooth.h ! Install it or use --disable-bluetooth";exit])
|
||||
+ AR_EXTRAFLAGS="$AR_EXTRAFLAGS -DUSE_BT_FBSD=1"
|
||||
+ AR_EXTRALIBS="$AR_EXTRALIBS -lbluetooth -lsdp"
|
||||
+ fi
|
||||
+ ;;
|
||||
+esac
|
||||
|
||||
AC_ARG_ENABLE(xtext,
|
||||
[ --disable-xtest disable xtest support])
|
||||
Only in anyremote-4.11-fbsd/: configure.in~
|
||||
Only in anyremote-4.11-fbsd/: configure.lineno
|
||||
diff -ur anyremote-4.11/src/Makefile.am anyremote-4.11-fbsd/src/Makefile.am
|
||||
--- src/Makefile.am 2008-09-29 20:54:38.000000000 +0200
|
||||
+++ src/Makefile.am 2008-10-31 13:08:21.000000000 +0100
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
|
||||
bin_PROGRAMS = anyremote
|
||||
-anyremote_SOURCES = atsend.c btio.c main.c cmds.c parse.c utils.c xemulate.c conf.c atsend.h common.h btio.h common.h parse.h cmds.h utils.h xemulate.h conf.h
|
||||
+anyremote_SOURCES = atsend.c btio.c main.c cmds.c parse.c utils.c xemulate.c conf.c atsend.h common.h btio.h common.h parse.h cmds.h utils.h xemulate.h conf.h getline.h getline.c
|
||||
anyremote_LDFLAGS = @LDFLAGS@
|
||||
anyremote_LDADD = @AR_EXTRALIBS@
|
||||
AM_CFLAGS = @AR_EXTRAFLAGS@
|
||||
diff -ur anyremote-4.11/src/btio.c anyremote-4.11-fbsd/src/btio.c
|
||||
--- src/btio.c 2008-09-29 20:54:38.000000000 +0200
|
||||
+++ src/btio.c 2008-11-01 20:04:02.000000000 +0100
|
||||
@@ -40,12 +40,19 @@
|
||||
#include <netdb.h>
|
||||
|
||||
//#define USE_BT
|
||||
+// #define USE_BT_FBSD
|
||||
|
||||
#ifdef USE_BT
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/rfcomm.h>
|
||||
#endif
|
||||
|
||||
+#ifdef USE_BT_FBSD
|
||||
+#include <bluetooth.h>
|
||||
+#include <sdp.h>
|
||||
+#include <err.h>
|
||||
+#endif
|
||||
+
|
||||
#include "btio.h"
|
||||
#include "common.h"
|
||||
#include "parse.h"
|
||||
@@ -576,6 +583,39 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
+#ifdef USE_BT_FBSD
|
||||
+void *session = NULL;
|
||||
+uint32_t record;
|
||||
+
|
||||
+
|
||||
+void sdpRegister(int port)
|
||||
+{
|
||||
+ int channel,service;
|
||||
+ bdaddr_t bt_addr_any;
|
||||
+ sdp_lan_profile_t lan;
|
||||
+
|
||||
+ channel = port;
|
||||
+ service = SDP_SERVICE_CLASS_SERIAL_PORT;
|
||||
+
|
||||
+ session = sdp_open_local(NULL);
|
||||
+ if (session == NULL)
|
||||
+ errx(1, "Unable to create local SDP session");
|
||||
+ if (sdp_error(session) != 0)
|
||||
+ errx(1, "Unable to open local SDP session. %s (%d)",
|
||||
+ strerror(sdp_error(session)), sdp_error(session));
|
||||
+ memset(&lan, 0, sizeof(lan));
|
||||
+ lan.server_channel = channel;
|
||||
+
|
||||
+ memcpy(&bt_addr_any, NG_HCI_BDADDR_ANY, sizeof(bt_addr_any));
|
||||
+ if (sdp_register_service(session, service, &bt_addr_any,
|
||||
+ (void *)&lan, sizeof(lan), &record) != 0) {
|
||||
+ errx(1, "Unable to register LAN service with "
|
||||
+ "local SDP daemon. %s (%d)",
|
||||
+ strerror(sdp_error(session)), sdp_error(session));
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
void sdpDeregister()
|
||||
{
|
||||
#ifdef USE_BT
|
||||
@@ -585,6 +625,13 @@
|
||||
//sdp_record_free(record);
|
||||
}
|
||||
#endif
|
||||
+ #ifdef USE_BT_FBSD
|
||||
+ if (session != NULL) {
|
||||
+ sdp_unregister_service(session, record);
|
||||
+ sdp_close(session);
|
||||
+ session = NULL;
|
||||
+ }
|
||||
+ #endif
|
||||
}
|
||||
|
||||
//
|
||||
@@ -598,11 +645,15 @@
|
||||
#ifdef USE_BT
|
||||
struct sockaddr_rc bt_addr;
|
||||
#endif
|
||||
+ #ifdef USE_BT_FBSD
|
||||
+ struct sockaddr_rfcomm bt_addr;
|
||||
+ #endif
|
||||
|
||||
struct sockaddr* socketaddr = NULL;
|
||||
|
||||
int addFamily = 0;
|
||||
int proto = 0;
|
||||
+ int sz;
|
||||
|
||||
if (sportfd) {
|
||||
logger("ERROR", "socket was already opened");
|
||||
@@ -619,6 +670,10 @@
|
||||
addFamily = PF_BLUETOOTH;
|
||||
proto = BTPROTO_RFCOMM;
|
||||
#endif
|
||||
+ #ifdef USE_BT_FBSD
|
||||
+ addFamily = PF_BLUETOOTH;
|
||||
+ proto = BLUETOOTH_PROTO_RFCOMM;
|
||||
+ #endif
|
||||
} else if (type == SERVER_UX) {
|
||||
addFamily = AF_UNIX;
|
||||
proto = 0;
|
||||
@@ -654,10 +709,12 @@
|
||||
tcp_addr.sin_port = htons(port);
|
||||
|
||||
socketaddr=(struct sockaddr *)&tcp_addr;
|
||||
+ sz = sizeof(tcp_addr);
|
||||
|
||||
} else if (type == SERVER_BT){ // SERVER_BT
|
||||
#ifdef USE_BT
|
||||
memset((void *) &bt_addr, 0, sizeof(bt_addr));
|
||||
+ sz = sizeof(bt_addr);
|
||||
|
||||
// bind socket to the specified port of the first available local bluetooth adapter
|
||||
bt_addr.rc_family = AF_BLUETOOTH;
|
||||
@@ -673,8 +730,21 @@
|
||||
sdpRegister(port);
|
||||
sprintf(tmp, "registered SP for channel %i", port);
|
||||
logger("INFO", tmp);
|
||||
+ socketaddr=(struct sockaddr *)&bt_addr;
|
||||
+ #endif
|
||||
+
|
||||
+ #ifdef USE_BT_FBSD
|
||||
+ memset(&bt_addr, 0, sizeof(bt_addr));
|
||||
|
||||
+ bt_addr.rfcomm_len = sizeof(bt_addr);
|
||||
+ bt_addr.rfcomm_family = AF_BLUETOOTH;
|
||||
+ bt_addr.rfcomm_channel = (uint8_t) port;;
|
||||
+ sdpRegister(port);
|
||||
+ sprintf(tmp, "registered SP for channel %i", port);
|
||||
+ logger("INFO", tmp);
|
||||
+
|
||||
socketaddr=(struct sockaddr *)&bt_addr;
|
||||
+ sz = sizeof(bt_addr);
|
||||
#endif
|
||||
} else if (type == SERVER_UX && path != NULL){
|
||||
|
||||
@@ -683,16 +753,16 @@
|
||||
strncpy(un_addr.sun_path, path, sizeof un_addr.sun_path - 1);
|
||||
printf("ERROR: SOCKET %s\n", path);
|
||||
socketaddr=(struct sockaddr *)&un_addr;
|
||||
+ sz = sizeof(un_addr);
|
||||
|
||||
} else {
|
||||
logger("ERROR", "incorrect input 2");
|
||||
return -1;
|
||||
}
|
||||
|
||||
- if (bind(sportfd, (struct sockaddr *) socketaddr, sizeof(*socketaddr)) < 0) {
|
||||
+ if (bind(sportfd, (struct sockaddr *) socketaddr, sz) < 0) {
|
||||
logger("ERROR", "on binding");
|
||||
printf("ERROR: on binding %d->%s\n", errno, strerror(errno));
|
||||
-
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -735,11 +805,15 @@
|
||||
bdaddr_t ba;
|
||||
#endif
|
||||
|
||||
+ #ifdef USE_BT_FBSD
|
||||
+ struct sockaddr_rfcomm bt_addr;
|
||||
+ #endif
|
||||
+
|
||||
logger("INFO", "listenAndAcceptSocketConn");
|
||||
cnt = 0;
|
||||
|
||||
if (type == SERVER_BT) {
|
||||
- #ifdef USE_BT
|
||||
+ #if defined(USE_BT) || defined(USE_BT_FBSD)
|
||||
socketaddr=(struct sockaddr *)&bt_addr;
|
||||
sz = sizeof(bt_addr);
|
||||
#endif
|
||||
@@ -789,7 +863,6 @@
|
||||
#ifdef USE_BT
|
||||
if (type == SERVER_BT) {
|
||||
baswap(&ba, &bt_addr.rc_bdaddr);
|
||||
-
|
||||
if (btAddress) {
|
||||
free(btAddress);
|
||||
}
|
||||
@@ -799,6 +872,17 @@
|
||||
logger("INFO", tmp);
|
||||
}
|
||||
#endif
|
||||
+ #ifdef USE_BT_FBSD
|
||||
+ if (type == SERVER_BT) {
|
||||
+ if (btAddress) {
|
||||
+ free(btAddress);
|
||||
+ }
|
||||
+ btAddress = strdup(bt_ntoa(&bt_addr.rfcomm_bdaddr, NULL));
|
||||
+
|
||||
+ sprintf(tmp, "listenAndAcceptSocketConn: remote BT address is %s", btAddress);
|
||||
+ logger("INFO", tmp);
|
||||
+ }
|
||||
+ #endif
|
||||
|
||||
break;
|
||||
}
|
||||
Only in anyremote-4.11-fbsd/src: btio.c~
|
||||
diff -ur anyremote-4.11/src/cmds.c anyremote-4.11-fbsd/src/cmds.c
|
||||
--- src/cmds.c 2008-10-01 20:23:20.000000000 +0200
|
||||
+++ src/cmds.c 2008-10-31 11:29:24.000000000 +0100
|
||||
@@ -39,6 +39,9 @@
|
||||
#include "parse.h"
|
||||
#include "utils.h"
|
||||
#include "xemulate.h"
|
||||
+#ifndef HAVE_GETLINE
|
||||
+ #include "getline.h"
|
||||
+#endif
|
||||
|
||||
extern void closePort(int final);
|
||||
extern int isConnected;
|
||||
Only in anyremote-4.11-fbsd/src: cmds.c~
|
||||
Only in anyremote-4.11-fbsd/src: fileManager.cfg
|
||||
Only in anyremote-4.11-fbsd/src: getline.c
|
||||
Only in anyremote-4.11-fbsd/src: getline.c~
|
||||
Only in anyremote-4.11-fbsd/src: getline.h
|
||||
Only in anyremote-4.11-fbsd/src: getline.h~
|
||||
diff -ur anyremote-4.11/src/main.c anyremote-4.11-fbsd/src/main.c
|
||||
--- src/main.c 2008-10-16 20:59:27.000000000 +0200
|
||||
+++ src/main.c 2008-11-01 20:33:35.000000000 +0100
|
||||
@@ -32,6 +32,9 @@
|
||||
#include <sys/wait.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
+#ifdef __FreeBSD__
|
||||
+ #include <signal.h>
|
||||
+#endif
|
||||
|
||||
#include "atsend.h"
|
||||
#include "btio.h"
|
||||
@@ -46,6 +49,8 @@
|
||||
#define ALARM_CLEAN 0
|
||||
#define ALARM_CHECK 1
|
||||
|
||||
+extern CONF conf;
|
||||
+
|
||||
static void mainRoutine (void);
|
||||
static int isBemusedCommand(char *cmd);
|
||||
static int isInpLircCommand(char *cmd);
|
||||
@@ -201,6 +206,13 @@
|
||||
}
|
||||
initialized++;
|
||||
}
|
||||
+
|
||||
+ // setgid
|
||||
+ if(conf.uid && getuid()==0){
|
||||
+ DEBUG2("setuid/setgid %d,%d",conf.uid,conf.gid);
|
||||
+ setgid(conf.gid);
|
||||
+ setuid(conf.uid);
|
||||
+ }
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -216,6 +228,9 @@
|
||||
closedir(d);
|
||||
} else {
|
||||
mkdir(dd, S_IRWXU);
|
||||
+ if(getuid()==0 && conf.uid) { // do not create as superuser
|
||||
+ chown(dd,conf.uid,conf.gid);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,8 +324,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- createDataDir();
|
||||
-
|
||||
if (argv[1] && (strcmp(argv[1],"-h")==0 || strcmp(argv[1],"--help")==0)) {
|
||||
//Just print help and exit
|
||||
printHelp();
|
||||
@@ -334,7 +347,8 @@
|
||||
freeCfg();
|
||||
exit(1);
|
||||
}
|
||||
-
|
||||
+
|
||||
+ createDataDir();
|
||||
initLog();
|
||||
|
||||
// Not to core dump if connection will close
|
||||
Only in anyremote-4.11-fbsd/src: main.c~
|
||||
Only in anyremote-4.11-fbsd/src: make.sh
|
||||
diff -ur anyremote-4.11/src/parse.c anyremote-4.11-fbsd/src/parse.c
|
||||
--- src/parse.c 2008-10-06 15:19:34.000000000 +0200
|
||||
+++ src/parse.c 2008-11-01 19:58:30.000000000 +0100
|
||||
@@ -50,7 +50,7 @@
|
||||
#define REGEX_TIMER "[[:space:]]*([^[:space:]]+)[[:space:]]*,[[:space:]]*([[:digit:]]*)[[:space:]]*,[[:space:]]*([[:digit:]]*)[[:space:]]*$|[[:space:]]*([^[:space:]]+)[[:space:]]*,[[:space:]]*(cancel|pause|continue)"
|
||||
#define REGEX_MAKE "[[:space:]]*(remote|mode|var)[[:space:]]*,[[:space:]]*(.*)[[:space:]]*|[[:space:]]*(exit|flush|disconnect|none)[[:space:]]*"
|
||||
|
||||
-#define REGEX_SET_TL "[[:space:]]*(fg|bg|font|select)[[:space:]]*,(.*)|[[:space:]]*(add|replace)[[:space:]]*,[[:space:]]*([^[:space:]]{1}[^,]*[^[:space:]]{1})[[:space:]]*,[[:space:]]*(.*)|[[:space:]]*(close)[[:space:]]*,[[:space:]]**(clear)[[:space:]]*|[[:space:]]*(clear|close|show)[[:space:]]*"
|
||||
+#define REGEX_SET_TL "[[:space:]]*(fg|bg|font|select)[[:space:]]*,(.*)|[[:space:]]*(add|replace)[[:space:]]*,[[:space:]]*([^[:space:]]{1}[^,]*[^[:space:]]{1})[[:space:]]*,[[:space:]]*(.*)|[[:space:]]*(close)[[:space:]]*,[[:space:]]*(clear)[[:space:]]*|[[:space:]]*(clear|close|show)[[:space:]]*"
|
||||
#define REGEX_SET_MN "[[:space:]]*(add|replace)[[:space:]]*,(.*)|[[:space:]]*(clear)[[:space:]]*"
|
||||
#define REGEX_SET_WM "[[:space:]]*(icon|window)[[:space:]]*,(.*)|[[:space:]]*(remove_all|show|close|cursor|nocursor|dynamic_cursor)[[:space:]]*|[[:space:]]*(set_cursor),[[:space:]]*(.*)[[:space:]]*"
|
||||
#define REGEX_SET_FM "[[:space:]]*(add|replace|select)[[:space:]]*,[[:space:]]*(left|right)[[:space:]]*,[[:space:]]*(.*)|[[:space:]]*(close|show)[[:space:]]*"
|
||||
@@ -85,7 +85,9 @@
|
||||
MODEL_DEFAULT, // Model
|
||||
NULL, // Cfg. dir
|
||||
-1, // Front-end port
|
||||
- 0}; // Work with anyremote2html
|
||||
+ 0, // Work with anyremote2html
|
||||
+ 0, // set uid
|
||||
+ 0}; // set gid
|
||||
|
||||
type_key* findExact(mode *mode, char *key)
|
||||
{
|
||||
@@ -216,6 +218,9 @@
|
||||
conf.http = 1;
|
||||
} else if (strcmp(argv[i],"--autoconnect")==0 || strcmp(argv[i],"-a")==0) {
|
||||
conf.autoConnect = 1;
|
||||
+ } else if (strcmp(argv[i],"--user")==0 || strcmp(argv[i],"-u")==0) {
|
||||
+ if(getUidGid(argv[++i], &conf.uid, &conf.gid)!=EXIT_OK)
|
||||
+ printf("WARNING: bad username %s\n", argv[i]);
|
||||
} else if (strcmp(argv[i],"-f")==0) {
|
||||
++i;
|
||||
continue; // already processed this parameter
|
||||
Only in anyremote-4.11-fbsd/src: parse.c~
|
||||
diff -ur anyremote-4.11/src/parse.h anyremote-4.11-fbsd/src/parse.h
|
||||
--- src/parse.h 2008-09-29 20:54:38.000000000 +0200
|
||||
+++ src/parse.h 2008-11-01 19:47:18.000000000 +0100
|
||||
@@ -23,6 +23,8 @@
|
||||
#define _PARSE_H_ 1
|
||||
|
||||
#include "common.h"
|
||||
+#include <sys/types.h>
|
||||
+#include <unistd.h>
|
||||
|
||||
#define CFGFILE "/.anyremote.cfg"
|
||||
|
||||
@@ -241,6 +243,8 @@
|
||||
char* cfgDir;
|
||||
int frontEnd;
|
||||
int http;
|
||||
+ uid_t uid;
|
||||
+ gid_t gid;
|
||||
} CONF;
|
||||
|
||||
|
||||
Only in anyremote-4.11-fbsd/src: parse.h~
|
||||
diff -ur anyremote-4.11/src/utils.c anyremote-4.11-fbsd/src/utils.c
|
||||
--- src/utils.c 2008-10-20 20:13:39.000000000 +0200
|
||||
+++ src/utils.c 2008-11-01 20:42:28.000000000 +0100
|
||||
@@ -23,12 +23,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <pwd.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
#include "conf.h"
|
||||
|
||||
+
|
||||
extern char tmp[MAXMAXLEN];
|
||||
+extern CONF conf;
|
||||
|
||||
// Some globals
|
||||
|
||||
@@ -91,7 +95,11 @@
|
||||
FILE *fplog = fopen(logfile, "w");
|
||||
if (fplog) {
|
||||
fclose(fplog);
|
||||
- }
|
||||
+ }
|
||||
+ if(getuid()==0 && conf.uid) { // do not open file as superuser
|
||||
+ chown(logfile,conf.uid,conf.gid);
|
||||
+ }
|
||||
+
|
||||
printConf();
|
||||
}
|
||||
}
|
||||
@@ -451,7 +459,9 @@
|
||||
printf(" -n do not send any AT+CKPD command to the phone\n");
|
||||
printf(" -a reconnect automatically in case of connection failure\n");
|
||||
printf(" -fe <port> work as backend for GUI frontend. Use specified port to connect to frontend.\n");
|
||||
- printf(" -http tune work with anyremote2html\n\n");
|
||||
+ printf(" -http tune work with anyremote2html\n");
|
||||
+ printf(" -u|--user <username> causes to run as a user other than root. \n\n");
|
||||
+
|
||||
}
|
||||
|
||||
int flushData()
|
||||
@@ -486,4 +496,21 @@
|
||||
flushAliases = NULL;
|
||||
}
|
||||
|
||||
+int getUidGid(char *username, uid_t *uid, gid_t *gid) {
|
||||
+ /* Set uid and gid to the preferred user (found in setuid.h). Can either be
|
||||
+ * numeric or a string, found in /etc/passwd. */
|
||||
+ struct passwd *pw;
|
||||
+
|
||||
+ if ((pw = getpwnam(username))) {
|
||||
+ // Name exists
|
||||
+ *uid = pw->pw_uid;
|
||||
+ *gid = pw->pw_gid;
|
||||
+ return EXIT_OK;
|
||||
+ }
|
||||
+ /* something Bad happened, so send back an error */
|
||||
+ return EXIT_NOK;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
Only in anyremote-4.11-fbsd/src: utils.c~
|
||||
diff -ur anyremote-4.11/src/utils.h anyremote-4.11-fbsd/src/utils.h
|
||||
--- src/utils.h 2008-09-29 20:54:38.000000000 +0200
|
||||
+++ src/utils.h 2008-11-01 19:52:34.000000000 +0100
|
||||
@@ -23,6 +23,8 @@
|
||||
#define _UTILS_H
|
||||
|
||||
#include "parse.h"
|
||||
+#include <sys/types.h>
|
||||
+#include <pwd.h>
|
||||
|
||||
#define LOGFILE "/anyremote.log"
|
||||
|
||||
@@ -78,4 +80,6 @@
|
||||
void setResFile (void);
|
||||
char* getResFile (void);
|
||||
|
||||
+int getUidGid(char *username, uid_t *uid, gid_t *gid) ;
|
||||
+
|
||||
#endif
|
|
@ -1,209 +0,0 @@
|
|||
diff -urN getline1/getline.c getline2/getline.c
|
||||
--- src/getline.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ src/getline.c 2008-10-31 13:10:57.000000000 +0100
|
||||
@@ -0,0 +1,176 @@
|
||||
+/* getline.c -- Replacement for GNU C library function getline
|
||||
+
|
||||
+Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
+
|
||||
+This program is free software; you can redistribute it and/or
|
||||
+modify it under the terms of the GNU General Public License as
|
||||
+published by the Free Software Foundation; either version 2 of the
|
||||
+License, or (at your option) any later version.
|
||||
+
|
||||
+This program is distributed in the hope that it will be useful, but
|
||||
+WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+General Public License for more details. */
|
||||
+
|
||||
+/* Written by Jan Brittenson, bson@gnu.ai.mit.edu. */
|
||||
+
|
||||
+#ifndef HAVE_GETLINE
|
||||
+#ifdef HAVE_CONFIG_H
|
||||
+#include <config.h>
|
||||
+#endif
|
||||
+
|
||||
+#include <sys/types.h>
|
||||
+#include <stdio.h>
|
||||
+#include <assert.h>
|
||||
+#include <errno.h>
|
||||
+#include "getline.h"
|
||||
+
|
||||
+#if STDC_HEADERS
|
||||
+#include <stdlib.h>
|
||||
+#else
|
||||
+char *malloc (), *realloc ();
|
||||
+#endif
|
||||
+
|
||||
+/* Always add at least this many bytes when extending the buffer. */
|
||||
+#define MIN_CHUNK 64
|
||||
+
|
||||
+/* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR
|
||||
+ + OFFSET (and null-terminate it). If LIMIT is non-negative, then
|
||||
+ read no more than LIMIT chars.
|
||||
+
|
||||
+ *LINEPTR is a pointer returned from malloc (or NULL), pointing to
|
||||
+ *N characters of space. It is realloc'd as necessary.
|
||||
+
|
||||
+ Return the number of characters read (not including the null
|
||||
+ terminator), or -1 on error or EOF. On a -1 return, the caller
|
||||
+ should check feof(), if not then errno has been set to indicate the
|
||||
+ error. */
|
||||
+
|
||||
+int
|
||||
+getstr (lineptr, n, stream, terminator, offset, limit)
|
||||
+ char **lineptr;
|
||||
+ size_t *n;
|
||||
+ FILE *stream;
|
||||
+ int terminator;
|
||||
+ int offset;
|
||||
+ int limit;
|
||||
+{
|
||||
+ int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
|
||||
+ char *read_pos; /* Where we're reading into *LINEPTR. */
|
||||
+ int ret;
|
||||
+
|
||||
+ if (!lineptr || !n || !stream)
|
||||
+ {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (!*lineptr)
|
||||
+ {
|
||||
+ *n = MIN_CHUNK;
|
||||
+ *lineptr = malloc (*n);
|
||||
+ if (!*lineptr)
|
||||
+ {
|
||||
+ errno = ENOMEM;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ *lineptr[0] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ nchars_avail = *n - offset;
|
||||
+ read_pos = *lineptr + offset;
|
||||
+
|
||||
+ for (;;)
|
||||
+ {
|
||||
+ int save_errno;
|
||||
+ register int c;
|
||||
+
|
||||
+ if (limit == 0)
|
||||
+ break;
|
||||
+ else
|
||||
+ {
|
||||
+ c = getc (stream);
|
||||
+
|
||||
+ /* If limit is negative, then we shouldn't pay attention to
|
||||
+ it, so decrement only if positive. */
|
||||
+ if (limit > 0)
|
||||
+ limit--;
|
||||
+ }
|
||||
+
|
||||
+ save_errno = errno;
|
||||
+
|
||||
+ /* We always want at least one char left in the buffer, since we
|
||||
+ always (unless we get an error while reading the first char)
|
||||
+ NUL-terminate the line buffer. */
|
||||
+
|
||||
+ assert((*lineptr + *n) == (read_pos + nchars_avail));
|
||||
+ if (nchars_avail < 2)
|
||||
+ {
|
||||
+ if (*n > MIN_CHUNK)
|
||||
+ *n *= 2;
|
||||
+ else
|
||||
+ *n += MIN_CHUNK;
|
||||
+
|
||||
+ nchars_avail = *n + *lineptr - read_pos;
|
||||
+ *lineptr = realloc (*lineptr, *n);
|
||||
+ if (!*lineptr)
|
||||
+ {
|
||||
+ errno = ENOMEM;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ read_pos = *n - nchars_avail + *lineptr;
|
||||
+ assert((*lineptr + *n) == (read_pos + nchars_avail));
|
||||
+ }
|
||||
+
|
||||
+ if (ferror (stream))
|
||||
+ {
|
||||
+ /* Might like to return partial line, but there is no
|
||||
+ place for us to store errno. And we don't want to just
|
||||
+ lose errno. */
|
||||
+ errno = save_errno;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (c == EOF)
|
||||
+ {
|
||||
+ /* Return partial line, if any. */
|
||||
+ if (read_pos == *lineptr)
|
||||
+ return -1;
|
||||
+ else
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ *read_pos++ = c;
|
||||
+ nchars_avail--;
|
||||
+
|
||||
+ if (c == terminator)
|
||||
+ /* Return the line. */
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ /* Done - NUL terminate and return the number of chars read. */
|
||||
+ *read_pos = '\0';
|
||||
+
|
||||
+ ret = read_pos - (*lineptr + offset);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+getline (lineptr, n, stream)
|
||||
+ char **lineptr;
|
||||
+ size_t *n;
|
||||
+ FILE *stream;
|
||||
+{
|
||||
+ return getstr (lineptr, n, stream, '\n', 0, GETLINE_NO_LIMIT);
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+getline_safe (lineptr, n, stream, limit)
|
||||
+ char **lineptr;
|
||||
+ size_t *n;
|
||||
+ FILE *stream;
|
||||
+ int limit;
|
||||
+{
|
||||
+ return getstr (lineptr, n, stream, '\n', 0, limit);
|
||||
+}
|
||||
+#endif /* HAVE_GETLINE */
|
||||
diff -urN getline1/getline.h getline2/getline.h
|
||||
--- src/getline.h 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ src/getline.h 2008-10-31 13:10:51.000000000 +0100
|
||||
@@ -0,0 +1,25 @@
|
||||
+#ifndef HAVE_GETLINE
|
||||
+#ifndef _getline_h_
|
||||
+#define _getline_h_ 1
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+
|
||||
+#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
+#define __PROTO(args) args
|
||||
+#else
|
||||
+#define __PROTO(args) ()
|
||||
+#endif /* GCC. */
|
||||
+
|
||||
+#define GETLINE_NO_LIMIT -1
|
||||
+
|
||||
+int
|
||||
+ getline __PROTO ((char **_lineptr, size_t *_n, FILE *_stream));
|
||||
+int
|
||||
+ getline_safe __PROTO ((char **_lineptr, size_t *_n, FILE *_stream,
|
||||
+ int limit));
|
||||
+int
|
||||
+ getstr __PROTO ((char **_lineptr, size_t *_n, FILE *_stream,
|
||||
+ int _terminator, int _offset, int limit));
|
||||
+
|
||||
+#endif /* _getline_h_ */
|
||||
+#endif /* HAVE_GETLINE */
|
|
@ -74,6 +74,12 @@ bin/anyremote
|
|||
%%DATADIR%%/cfg-data/Server-mode/listen.cfg
|
||||
%%DATADIR%%/cfg-data/Server-mode/exaile.cfg
|
||||
%%DATADIR%%/cfg-data/Server-mode/banshee-v2.cfg
|
||||
%%DATADIR%%/cfg-data/Server-mode/amarok2.cfg
|
||||
%%DATADIR%%/cfg-data/Server-mode/gwenview2.cfg
|
||||
%%DATADIR%%/cfg-data/Server-mode/juk2.cfg
|
||||
%%DATADIR%%/cfg-data/Server-mode/okular.cfg
|
||||
%%DATADIR%%/cfg-data/Server-mode/wmctrl.cfg
|
||||
%%DATADIR%%/cfg-data/Server-mode/xbmc.cfg
|
||||
%%DATADIR%%/cfg-data/Utils/gradient.png
|
||||
%%DATADIR%%/cfg-data/Utils/all-in-1.py
|
||||
%%DATADIR%%/cfg-data/Utils/xmms_is_playing
|
||||
|
@ -251,12 +257,14 @@ bin/anyremote
|
|||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/thanks.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/ev-handlers.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/set-menu.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/index.html.dup
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/conf-at.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/set-icons.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/install.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/dload.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/devices.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/ar-lirc.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/inputlirc.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/tips-tricks.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/contacts.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/vars.html
|
||||
%%PORTDOCS%%%%DOCSDIR%%/doc-html/ckpd-emulation.html
|
||||
|
|
Loading…
Reference in a new issue