[Momonga-devel.ja:01888] Re: 固定 uid, gid


tamo です。

On Thu, 06 Feb 2003, HOSONO Hidetomo wrote:

>   > だけなのでこれに id 割り振って、パッケージが要求するユーザ、グループの
>   > uid, gid を固定にしようかと思うのですがどうでしょ。
> 
> just ideaレベルで(ボロはあると思うけど、一応)提案しておきます。
> 
> 人間様が定めたルールと実装がシンクロするよう、
> /usr/lib/rpm/macros、もしくはそこでincludeされる別ファイルで
> マクロ定義されていると嬉しいかもしれません。
> 
> フォーマットは
> 
>   %_uid_<ユーザ名> 番号
>   %_gid_<グループ名> 番号

これもやります?
nomail を対応させるとしたら、こんな感じかな。
これまで、最初にインストールするとき
%pre で nomail という uid と gid が作られるけど
実際には root が使われてしまうという問題が
あった気がしたので、%attr に数字が入るように
してみたり。

-- 
tamo
Index: nomail/nomail.spec
===================================================================
RCS file: /home/cvs/pkgs/nomail/nomail.spec,v
retrieving revision 1.18
diff -u -r1.18 nomail.spec
--- nomail/nomail.spec	2 Feb 2003 14:00:35 -0000	1.18
+++ nomail/nomail.spec	8 Jul 2003 07:27:20 -0000
@@ -1,7 +1,12 @@
+%define momorel 11
+
+%{?!_uid_nomail: %define _uid_nomail 111}
+%{?!_gid_nomail: %define _gid_nomail 111}
+
 Summary: Nomail - offline SMTP server
 Name: nomail
 Version: 0.4.10
-Release: 10m
+Release: %{momorel}m
 Group: System Environment/Daemons
 # Source0: ftp://ftp.KU3G.org/pub/nomail/%{name}-%{version}.tar.gz
 # Source0: http://www.ku3g.org/negi/nomail/%{name}-%{version}.tar.gz
@@ -50,8 +55,14 @@
 rm -rf %{buildroot}
 
 %pre
+grep nomail /etc/passwd >/dev/null 2>&1 || \
+grep nomail /etc/group  >/dev/null 2>&1 || \
+( \
+groupadd -g %{_gid_nomail} nomail && \
 useradd -M -r -d /dev/null -s /dev/null \
-	-c "Nomail SMTP server" nomail >/dev/null 2>&1 || :
+	-u %{_uid_nomail} -g nomail \
+	-c "Nomail SMTP server" nomail \
+)
 grep nomail /etc/passwd >/dev/null 2>&1
 grep nomail /etc/group  >/dev/null 2>&1
 
@@ -63,15 +74,20 @@
 %files
 %defattr(-,root,root)
 %config(noreplace) /etc/nomail.conf
-%attr(4711,nomail,nomail) %{_sbindir}/nomail
+%attr(4711,%{_uid_nomail},%{_gid_nomail}) %{_sbindir}/nomail
 %{_sbindir}/sendmail
-%attr(4711,nomail,nomail) %{_bindir}/nosend
-%attr(0700,nomail,nomail) /var/nomail
+%attr(4711,%{_uid_nomail},%{_gid_nomail}) %{_bindir}/nosend
+%attr(0700,%{_uid_nomail},%{_gid_nomail}) /var/nomail
 %{_mandir}/ja/man8/*
 %config(missingok,noreplace) /etc/xinetd.d/smtp
 %doc COPYING ChangeLog FAQ INSTALL README VERSION nomail.txt nosend.txt
 
 %ChangeLog
+* Tue Jul 08 2003 TAKAHASHI Tamotsu <tamo>
+- (0.4.10-11m)
+- disable xinetd access by default
+- use _uid_nomail and _gid_nomail
+
 * Sun Feb 02 2003 TAKAHASHI Tamotsu
 - (0.4.10-10m)
 - remove Requires: perl-MIME-Base64 and perl-Jcode
Index: nomail/xinet.d.ftp.sample
===================================================================
RCS file: /home/cvs/pkgs/nomail/xinet.d.ftp.sample,v
retrieving revision 1.3
diff -u -r1.3 xinet.d.ftp.sample
--- nomail/xinet.d.ftp.sample	2 Feb 2003 14:00:35 -0000	1.3
+++ nomail/xinet.d.ftp.sample	8 Jul 2003 07:27:20 -0000
@@ -1,5 +1,6 @@
 service smtp
 {
+	disable = yes
 	flags	= REUSE
 	socket_type	= stream
 	wait	= no