Solved

Query Regarding RPM spec file

Posted on 2012-04-12
11
805 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now