Solved

Query Regarding RPM spec file

Posted on 2012-04-12
11
823 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
linux 13 99
EXCHANGE. LINUX, SYMANTEC MESSAGING GATEWAY 2 49
Samba 4, Users Permission, 5 62
Exchange Server Send connector and DNS Round Robin ? 6 40
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 …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

740 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