Solved

Query Regarding RPM spec file

Posted on 2012-04-12
11
831 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

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…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

695 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