Bug 187110 - comms/gammu can't drop privileges
Summary: comms/gammu can't drop privileges
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Boris Samorodov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-27 15:40 UTC by Lukasz Wasikowski
Modified: 2014-03-28 14:20 UTC (History)
0 users

See Also:


Attachments
file.diff (877 bytes, patch)
2014-02-27 15:40 UTC, Lukasz Wasikowski
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lukasz Wasikowski 2014-02-27 15:40:00 UTC
gammu's configure on FreeBSD can't find initgroups(), which results in lack of privilege drop for gammu-smsd:

# gammu-smsd -h
usage: gammu-smsd [OPTION]...
options:
-h / --help - shows this help
-v / --version - shows version information
-c / --config CONFIG_FILE - defines path to config file
-d / --daemon - daemonizes program after startup
-p / --pid PID_FILE - defines path to pid file
-f / --max-failures NUM - number of failures before terminating
-X / --suicide SECONDS - kills itself after number of seconds
-l / --use-log - use logging configuration from config file (default)
-L / --no-use-log - do not use logging configuration from config file


With attached patch use of --user and --group is possible:

# gammu-smsd -h
usage: gammu-smsd [OPTION]...
options:
-h / --help - shows this help
-v / --version - shows version information
-c / --config CONFIG_FILE - defines path to config file
-d / --daemon - daemonizes program after startup
-p / --pid PID_FILE - defines path to pid file
-U / --user USER - run daemon as a user
-G / --group GROUP - run daemon as a group
-f / --max-failures NUM - number of failures before terminating
-X / --suicide SECONDS - kills itself after number of seconds
-l / --use-log - use logging configuration from config file (default)
-L / --no-use-log - do not use logging configuration from config file

Fix: Patch attached with submission follows:
Comment 1 Edwin Groothuis freebsd_committer 2014-02-27 15:40:08 UTC
Responsible Changed
From-To: freebsd-ports-bugs->bsam

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 dfilter service freebsd_committer 2014-03-28 14:11:05 UTC
Author: bsam
Date: Fri Mar 28 14:10:58 2014
New Revision: 349424
URL: http://svnweb.freebsd.org/changeset/ports/349424
QAT: https://qat.redports.org/buildarchive/r349424/

Log:
  . let drop privileges at gammu-smsd;  [1]
  . support STAGE;
  . add LICENSE (GPLv2);
  . add ftp/curl to LIB_DEPENDS;
  . add pkgconfig, shebangfix to USES;
  . use /bin/sh instead /bin/bash at two scripts;
  . add USE_LDCONFIG=yes (the port installs shared libs);
  . remove bash from BUILD_DEPENDS (bash completion does not need it);
  . bump PORTREVISION.
  
  PR:		ports/187110  [1]
  Submitted by:	Lukasz Wasikowski <lukasz@wasikowski.net>  [1]

Modified:
  head/comms/gammu/Makefile
  head/comms/gammu/files/patch-CMakeLists.txt
  head/comms/gammu/pkg-plist

Modified: head/comms/gammu/Makefile
==============================================================================
--- head/comms/gammu/Makefile	Fri Mar 28 14:07:47 2014	(r349423)
+++ head/comms/gammu/Makefile	Fri Mar 28 14:10:58 2014	(r349424)
@@ -3,6 +3,7 @@
 
 PORTNAME=	gammu
 PORTVERSION=	1.33.0
+PORTREVISION=	1
 CATEGORIES=	comms
 MASTER_SITES=	http://dl.cihar.com/gammu/releases/ \
 		http://dl.cihar.com.nyud.net/gammu/releases/
@@ -10,6 +11,9 @@ MASTER_SITES=	http://dl.cihar.com/gammu/
 MAINTAINER=	bsam@FreeBSD.org
 COMMENT=	GNU All Mobile Management Utilities
 
+LICENSE=	GPLv2
+
+LIB_DEPENDS=	libcurl.so:${PORTSDIR}/ftp/curl
 RUN_DEPENDS=	cdialog:${PORTSDIR}/devel/cdialog
 
 CONFLICTS=	gammu-devel-[1-9]* gammu-python-[1-9]*
@@ -18,27 +22,29 @@ OPTIONS_DEFINE=	BASH
 
 CMAKE_ARGS+=	-DINSTALL_LIBDATA_DIR=${LOCALBASE}/libdata
 
-USES=		cmake gettext
+USES=		cmake gettext pkgconfig shebangfix
+SHEBANG_FILES=	utils/jadmaker utils/gammu-config
+bash_CMD=	/bin/sh
 USE_PYTHON=	yes
 USE_GNOME=	glib20
+USE_LDCONFIG=	yes
 
 PORTDOCS=	*
 
-NO_STAGE=	yes
 post-patch:
-	@${REINPLACE_CMD} -i '' -e 's:bash:sh:' -e 's:dialog:cdialog:' ${WRKSRC}/utils/gammu-config
 	@${REINPLACE_CMD} -i '' -e 's:/etc/bash_completion.d:${PREFIX}/etc/bash_completion.d:' \
 		${WRKSRC}/contrib/CMakeLists.txt
 
 post-install:
-.for opt in -Qold -O
-	${PYTHON_CMD} ${opt} -m compileall -l ${PYTHONPREFIX_SITELIBDIR}/gammu
-.endfor
+	(cd ${STAGEDIR}${PREFIX} && \
+	${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py \
+		-d ${PYTHONPREFIX_SITELIBDIR} -f ${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} && \
+	${PYTHON_CMD} -O ${PYTHON_LIBDIR}/compileall.py \
+		-d ${PYTHONPREFIX_SITELIBDIR} -f ${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;})
 
 .include <bsd.port.options.mk>
 
 .if ${PORT_OPTIONS:MBASH}
-BUILD_DEPENDS+=	bash:${PORTSDIR}/shells/bash
 RUN_DEPENDS+=	bash:${PORTSDIR}/shells/bash
 PLIST_FILES+=	etc/bash_completion.d/gammu
 PLIST_DIRSTRY+=	etc/bash_completion.d
@@ -46,17 +52,4 @@ PLIST_DIRSTRY+=	etc/bash_completion.d
 EXTRA_PATCHES+=	${FILESDIR}/extra-patch-contrib_CMakeLists.txt
 .endif
 
-.if ${PORT_OPTIONS:MDOCS}
-MAN1=		gammu.1 gammu-config.1 jadmaker.1 gammu-smsd.1 gammu-smsd-inject.1 \
-		gammu-smsd-monitor.1 gammu-detect.1
-MAN5=		gammu-backup.5 gammu-smsbackup.5 gammu-smsdrc.5 gammurc.5
-MAN7=		gammu-smsd-files.7 gammu-smsd-mysql.7 \
-		gammu-smsd-odbc.7 gammu-smsd-pgsql.7 \
-		gammu-smsd-dbi.7 gammu-smsd-tables.7 gammu-smsd-null.7 \
-		gammu-smsd-run.7 gammu-smsd-sql.7
-.else
-CMAKE_ARGS+=	-DINSTALL_DOC=OFF -DINSTALL_PHP_EXAMPLES=OFF -DINSTALL_MEDIA=OFF \
-		-DINSTALL_GNAPPLET=OFF
-.endif
-
 .include <bsd.port.mk>

Modified: head/comms/gammu/files/patch-CMakeLists.txt
==============================================================================
--- head/comms/gammu/files/patch-CMakeLists.txt	Fri Mar 28 14:07:47 2014	(r349423)
+++ head/comms/gammu/files/patch-CMakeLists.txt	Fri Mar 28 14:10:58 2014	(r349424)
@@ -1,5 +1,14 @@
 --- CMakeLists.txt.orig	2011-12-21 17:25:37.000000000 +0400
 +++ CMakeLists.txt	2011-12-23 14:57:04.447118270 +0400
+@@ -120,7 +120,7 @@
+ check_symbol_exists (getgrnam "grp.h" HAVE_GETGRNAM)
+ check_symbol_exists (getpwuid "pwd.h" HAVE_GETPWUID)
+ check_symbol_exists (getuid "unistd.h" HAVE_GETUID)
+-check_symbol_exists (initgroups "grp.h" HAVE_INITGROUPS)
++check_symbol_exists (initgroups "unistd.h" HAVE_INITGROUPS)
+ check_symbol_exists (setuid "unistd.h" HAVE_SETUID)
+ check_symbol_exists (setgid "unistd.h" HAVE_SETGID)
+ check_symbol_exists (SIGHUP "signal.h" HAVE_SIGHUP)
 @@ -656,7 +656,7 @@ mark_as_advanced (INSTALL_DATA_DIR)
  set (INSTALL_DOC_DIR "share/doc/gammu" CACHE STRING "Path for documentation installation")
  mark_as_advanced (INSTALL_DOC_DIR)

Modified: head/comms/gammu/pkg-plist
==============================================================================
--- head/comms/gammu/pkg-plist	Fri Mar 28 14:07:47 2014	(r349423)
+++ head/comms/gammu/pkg-plist	Fri Mar 28 14:10:58 2014	(r349424)
@@ -1,5 +1,6 @@
 bin/gammu
 bin/gammu-config
+bin/gammu-detect
 bin/gammu-smsd
 bin/gammu-smsd-inject
 bin/gammu-smsd-monitor
@@ -40,6 +41,26 @@ lib/libGammu.so.7.1.33.0
 lib/libgsmsd.so
 lib/libgsmsd.so.7
 lib/libgsmsd.so.7.1.33.0
+man/man1/gammu-config.1.gz
+man/man1/gammu-detect.1.gz
+man/man1/gammu-smsd-inject.1.gz
+man/man1/gammu-smsd-monitor.1.gz
+man/man1/gammu-smsd.1.gz
+man/man1/gammu.1.gz
+man/man1/jadmaker.1.gz
+man/man5/gammu-backup.5.gz
+man/man5/gammu-smsbackup.5.gz
+man/man5/gammu-smsdrc.5.gz
+man/man5/gammurc.5.gz
+man/man7/gammu-smsd-dbi.7.gz
+man/man7/gammu-smsd-files.7.gz
+man/man7/gammu-smsd-mysql.7.gz
+man/man7/gammu-smsd-null.7.gz
+man/man7/gammu-smsd-odbc.7.gz
+man/man7/gammu-smsd-pgsql.7.gz
+man/man7/gammu-smsd-run.7.gz
+man/man7/gammu-smsd-sql.7.gz
+man/man7/gammu-smsd-tables.7.gz
 share/gammu/gammu-s60-remote.sis
 share/gammu/gnapplet.ini
 share/gammu/gnapplet.sis
@@ -132,3 +153,5 @@ share/locale/zh_TW/LC_MESSAGES/libgammu.
 @dirrm share/gammu
 @dirrm include/gammu
 @dirrm %%PYTHON_SITELIBDIR%%/gammu
+@dirrmtry %%PYTHON_SITELIBDIR%%
+@dirrmtry %%PYTHON_LIBDIR%%
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 3 Boris Samorodov freebsd_committer 2014-03-28 14:12:36 UTC
State Changed
From-To: open->closed

Committed, thanks!