update files in a solaris package without rebuilding the package

Contributor Icon Contributed by Michilimackinac Date Icon April 1, 2004  
Tag Icon Tagged: Solaris




Note: please save a backup copy of your package before attempting this.


% grep "sudoers " pkgmap
1 f none /etc/sudoers 0440 root root 324 27801 1080878491
%

where 324 is the size of the file (ls -l)
where 27801 is the checksum (/usr/bin/sum)
and 1080878491 is the modification time of the file in seconds since the epoch (modtime)

I created the modtime program since I knew of no way to obtain a file’s modification time in units of seconds since the epoch.

Here is the source (solaris 9):


/*
* modtime
*
* This Program was created to display the modification time of
* a file in units of seconds since the epoch
*
*/

#include
#include
#include

int main(int argc, char *argv[])
{
struct stat filestats;
stat(argv[1],&filestats);
printf(”modification time: %15d\n”,filestats.st_mtim.tv_sec);
}

I also created a script (pkgremap) to combine the size, sum, and modtime in a format similar to pkgmap:


#!/bin/sh
#
# pkgremap

/usr/bin/ls -l $1 | /usr/bin/awk '{printf "%s ",$5}'
/usr/bin/sum $1 | /usr/bin/awk '{printf "%s ",$1}'
/path_to_modtime/modtime $1 | /usr/bin/awk '{printf "%s\n",$NF}'

Knowing this assume we want to update a package the we have created for using “sudo”. Let’s say this is our original sudoers file the comes with the package


# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# User privilege specification
victoria ALL=(ALL) ALL

But now we have another system admin that came on board though we do not want compile another version of the package. Assuming we are in the directory of the package (should see a pkginfo and a pkgmap here with an “ls”). We can cd to the location of the file in this case root/etc. Now we can make our addition to the file:


# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# User privilege specification
victoria ALL=(ALL) ALL
mackenzie ALL=(ALL) ALL

run the script pkgremap:


% ~/pkgremap sudoers
348 29596 1080878786
%

edit the pkgmap entry
1 f none /etc/sudoers 0440 root root 348 29596 1080878786

install the package with the updated sudoers file

Previous recipe | Next recipe |
 

 
close Reblog this comment
blog comments powered by Disqus