Solved

Query Regarding RPM spec file

Posted on 2012-04-12
11
812 Views
Last Modified: 2012-06-27
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"
0
Comment
Question by:sudhirgoogle
11 Comments
 
LVL 3

Expert Comment

by:skymo
ID: 37836826
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)
0
 
LVL 1

Author Comment

by:sudhirgoogle
ID: 37836938
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 ?
0
 
LVL 1

Author Comment

by:sudhirgoogle
ID: 37837310
Please advice ASAP
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 34

Expert Comment

by:Duncan Roe
ID: 37868227
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------
0
 
LVL 1

Author Comment

by:sudhirgoogle
ID: 37869282
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 ?
0
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 250 total points
ID: 37870226
umask is a property of a process, not of a directory.
umask is per-session. I cannot say whether RPM remembers what it was, changes it for the install, then changes it back to what it was - the fact that it's specified in post-install suggests that it might, but you'd have to try with an unusual umask value to be sure.
Although umask is per-session, commonly it's set by /etc/profile so everyone gets the same one (except possibly root, which /etc/profile may treat specially (it usually does for PATH)). Any user may change their .bashrc or whatever to set umask to their taste, or change their umask directly.
RPM might set umask to ensure whatever it installs is world-readable / world-executable. This would be important at a site that defaults to umask 007 (I did work at such a site once).
0
 
LVL 16

Assisted Solution

by:The--Captain
The--Captain earned 250 total points
ID: 37879268
All that is happening is that the spec file is telling the build process what permissions to use when creating the files in the package (umask of 022 = permissions of 755), except for /opt/cps/platform/sips, which gets permissions of 777.  This ONLY pertains to the build/install.  Umasks for subsequent execution of any package binaries are either determined by the environment or the code of the executable itself.

Again, the specfile only pertains to package building/installation.

May I ask why you care?

Cheers,
-Jon
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 37880093
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).
0
 
LVL 1

Author Closing Comment

by:sudhirgoogle
ID: 37935841
Thanks for your solution
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
su - oracle could not open session 6 75
Choosing CentOS 16 80
awk variable in printf 1 25
EXCHANGE. LINUX, SYMANTEC MESSAGING GATEWAY 2 16
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question