Link to home
Start Free TrialLog in
Avatar of sudhirgoogle
sudhirgoogle

asked on

Query Regarding RPM spec file

Hello Experts,

I am dealing with RPM spec file as shown below, could you please explain me  what exactly the 'umask 022'  command does during the installation and uninstall ?? to which directory it sets those permission and spec file also has 'chmod 777 /opt/cps/platform/sips' command. what is the order of precedence.

#=Begin Preamble=================================================
# (C) platformyright 2008 cps Systems, Inc.
#   Name : opensips.spec
#   Description :cps Repackaged opensips 1.8
#   03/23/2012   cps   Initial Version , David
#=End Preamble===================================================

Group: DevBase
License: None
Name: cps-opensips
Version: %PRODUCT_VERSION
Release: 1
Summary: cps repackaged opensips package.
Vendor: cps Systems, Inc

provides: cps-opensips
#requires: linux base only

%description
Repackaged OpenSips as the SIP Server Proxy providor for Voipserver.
This package is intended to provide sips for platform  

%files
%attr(0500, root,root) /opt/cps/platform/sips/install_sips.sh
%attr(0666, root,root) /opt/cps/platform/sips/*

%pre
umask 022
echo "Inside %pre section"
if [ "$1" = "1" ];
then
	mkdir -p  /opt/cps/platform/sips
	chmod 777 /opt/cps/platform/sips
fi

%post
umask 022
echo "Inside %post section"
if [ "$1" = "1" ];
then
        echo "--- Installing cps-opensips as sips package --- "
        cd /opt/cps/platform/sips/
        /bin/bash ./install_sips.sh
        RC=$?
        [ "$RC" == "0" ] || echo "ERROR:Sips Installer exit code $RC"
        [ "$RC" == "0" ] || exit 1
fi
exit 0

%postun
echo "Inside %postun section"

%preun
echo "Inside %preun section"
Avatar of skymo
skymo
Flag of Israel image

umask set the default system wide file creation permission mask. that means that when ever
a file is created its permission are masked by the umask value; e.g permission of 777 with
umask 022 result in 777 & ~022 --> 755 (rwxr-xr-x)
Avatar of sudhirgoogle
sudhirgoogle

ASKER

umask mention in both %pre and %post section, is that mandotory ??

what will happen if i didn't specify umask in spec file ?

%attr(0500, root,root) /opt/cps/platform/sips/install_sips.sh  -> after installation what will be the permission for this file ?
Please advice ASAP
Avatar of Duncan Roe
Not specifying umask would lead to you getting whatever it was set to beforehand (you always have a umask setting).
%attr(0500, root,root) /opt/cps/platform/sips/install_sips.sh owner root, group root, permissions -r-x------
Thanks duncan_roe. As per my understanding we cann't set umask for particular folder, when we set umask its applicable to complete file-system hierarchy, including the ' /  ' root filesystem .--->  is my understanding  correct ??

the umask set by RPM will remain persistent after reboot ??

just for sake of successful installation,  RPM temporarily sets the umask for the whole linux filesystem so that it won't run into permission issues -> is my understanding correct ?
ASKER CERTIFIED SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Now I come to think of it, any umask set by RPM Installer is lost when it terminates (because that process has terminated and umask is per-process).
(I tested this by starting a shell and changing its umask. New umask is lost when shell exits).
Thanks for your solution