Operating System - HP-UX
1828960 Members
2093 Online
109986 Solutions
New Discussion

clean_tmps for /tmp and /var/tmp

 
Christina Martin
Frequent Advisor

clean_tmps for /tmp and /var/tmp

we have our system configured to clean these directories.

because of security restrictions we've had to set the sticky bit on these directories.

clean_tmps will NOT delete the files in /tmp or /var/tmp and we believe it's because of the sticky bit.

anyone run into this before? what was your solution?
12 REPLIES 12
Hasan  Atasoy
Honored Contributor

Re: clean_tmps for /tmp and /var/tmp

hi cristiana;

did you change default value in /etc/rc.config.d/clean_tmps
CLEAR_TMP=1

?

HAsan
Christina Martin
Frequent Advisor

Re: clean_tmps for /tmp and /var/tmp

yes. that definition has been set as well.

We just removed the sticky bit from /var/tmp, ran clean_tmps and it still didn't clear /var/tmp.

SO, back to the drawing board...
Lisa
Hasan  Atasoy
Honored Contributor

Re: clean_tmps for /tmp and /var/tmp

hi crstiana,

if you look at clean_tmps script it does not clean /var/tmp directoy . it just clean /tmp and list files in /var/tmp

Hasan
James R. Ferguson
Acclaimed Contributor

Re: clean_tmps for /tmp and /var/tmp

Hi Christina:

It is always helpful when diagnosing startup script problems to examine the '/etc/rc.log'.

Since startup scripts run as root, setting the sticky bit to restrict file removal to the file's owner is immaterial in this case.

Regards!

...JRF...
VK2COT
Honored Contributor

Re: clean_tmps for /tmp and /var/tmp

Hello,

You obviously run HP-UX 11.1 or 11.23.
They are not designed to automate
cleanup of /var/tmp at boot time.
/etc/rc.config.d/clean_tmps was
only meant for cleaning up /tmp.

However, you could modify /sbin/init.d/clean_tmps and
replace the following lines:

orig_dir="/" # we start out at '/' (root)
cd /tmp
if [ $? -ne 0 ]; then
echo "ERROR: could not change to directory "
echo "ERROR: no cleaning done"
rval=1
else
echo "NOTE: Clearing files from /tmp"
# ll |grep "^d.*"|awk '{print $9}'|grep -v "lost+found"|xargs rm -rf
#
# fix for DSDe443580: Begin :
# /sbin/init.d/clean_tmps script fails with large numbers of files in the
# /tmp directory.
# rm command was failing because the argument list was greater than ARG_MAX.
# xargs(1) is used to limit the argument size of rm to ARG_MAX.
#
# Fix for Defect JAGab68614 : Bad Patch PHCO_15932
# clean_tmps script will fail if the /tmp directory contains -name file types.
# "rm -rf" is changed to "rm -rf --"
ls | grep -v "lost+found" | xargs rm -rf --
rm lost+found 2>/dev/null
# DSDe443580 : End :
fi
cd $orig_dir

with something like:

orig_dir="/" # we start out at '/' (root)
for cldir in "/tmp /var/tmp"
do
cd /$cldir
if [ $? -ne 0 ]; then
echo "ERROR: could not change to directory <$cldir>"
echo "ERROR: no cleaning done"
rval=1
else
echo "NOTE: Clearing files from $cldir"
# ll |grep "^d.*"|awk '{print $9}'|grep -v "lost+found"|xargs rm -rf
#
# fix for DSDe443580: Begin :
# /sbin/init.d/clean_tmps script fails with large numbers of files in the
# /tmp directory.
# rm command was failing because the argument list was greater than ARG_MAX.
# xargs(1) is used to limit the argument size of rm to ARG_MAX.
#
# Fix for Defect JAGab68614 : Bad Patch PHCO_15932
# clean_tmps script will fail if the /tmp directory contains -name file types.
# "rm -rf" is changed to "rm -rf --"
ls | grep -v "lost+found" | xargs rm -rf --
rm lost+found 2>/dev/null
# DSDe443580 : End :
fi
cd $orig_dir
done

Note that each patch upgrade will possibly
overwrite /sbin/init.d/clean_tmps so
you need to save the customized copy of
the file...

Cheers,

Dusan
VK2COT - Dusan Baljevic
VK2COT
Honored Contributor

Re: clean_tmps for /tmp and /var/tmp

Hello,

They are not designed to automate
cleanup of /var/tmp at boot time.
/etc/rc.config.d/clean_tmps was
only meant for cleaning up /tmp.

However, you could modify /sbin/init.d/clean_tmps and
replace the following lines:

orig_dir="/" # we start out at '/' (root)
cd /tmp
if [ $? -ne 0 ]; then
echo "ERROR: could not change to directory "
echo "ERROR: no cleaning done"
rval=1
else
echo "NOTE: Clearing files from /tmp"
# ll |grep "^d.*"|awk '{print $9}'|grep -v "lost+found"|xargs rm -rf
#
# fix for DSDe443580: Begin :
# /sbin/init.d/clean_tmps script fails with large numbers of files in the
# /tmp directory.
# rm command was failing because the argument list was greater than ARG_MAX.
# xargs(1) is used to limit the argument size of rm to ARG_MAX.
#
# Fix for Defect JAGab68614 : Bad Patch PHCO_15932
# clean_tmps script will fail if the /tmp directory contains -name file types.
# "rm -rf" is changed to "rm -rf --"
ls | grep -v "lost+found" | xargs rm -rf --
rm lost+found 2>/dev/null
# DSDe443580 : End :
fi
cd $orig_dir

with something like:

orig_dir="/" # we start out at '/' (root)
for cldir in "/tmp /var/tmp"
do
cd /$cldir
if [ $? -ne 0 ]; then
echo "ERROR: could not change to directory <$cldir>"
echo "ERROR: no cleaning done"
rval=1
else
echo "NOTE: Clearing files from $cldir"
# ll |grep "^d.*"|awk '{print $9}'|grep -v "lost+found"|xargs rm -rf
#
# fix for DSDe443580: Begin :
# /sbin/init.d/clean_tmps script fails with large numbers of files in the
# /tmp directory.
# rm command was failing because the argument list was greater than ARG_MAX.
# xargs(1) is used to limit the argument size of rm to ARG_MAX.
#
# Fix for Defect JAGab68614 : Bad Patch PHCO_15932
# clean_tmps script will fail if the /tmp directory contains -name file types.
# "rm -rf" is changed to "rm -rf --"
ls | grep -v "lost+found" | xargs rm -rf --
rm lost+found 2>/dev/null
# DSDe443580 : End :
fi
cd $orig_dir
done

Note that each patch upgrade will possibly
overwrite /sbin/init.d/clean_tmps so
you need to save the customized copy of
the file...

Cheers,

Dusan
VK2COT - Dusan Baljevic
VK2COT
Honored Contributor

Re: clean_tmps for /tmp and /var/tmp

Hello,

They are not designed to automate
cleanup of /var/tmp at boot time.
/etc/rc.config.d/clean_tmps was
only meant for cleaning up /tmp.

However, you could modify /sbin/init.d/clean_tmps and
replace the following lines:

orig_dir="/" # we start out at '/' (root)
cd /tmp
if [ $? -ne 0 ]; then
echo "ERROR: could not change to directory "
echo "ERROR: no cleaning done"
rval=1
else
echo "NOTE: Clearing files from /tmp"
# ll |grep "^d.*"|awk '{print $9}'|grep -v "lost+found"|xargs rm -rf
#
# fix for DSDe443580: Begin :
# /sbin/init.d/clean_tmps script fails with large numbers of files in the
# /tmp directory.
# rm command was failing because the argument list was greater than ARG_MAX.
# xargs(1) is used to limit the argument size of rm to ARG_MAX.
#
# Fix for Defect JAGab68614 : Bad Patch PHCO_15932
# clean_tmps script will fail if the /tmp directory contains -name file types.
# "rm -rf" is changed to "rm -rf --"
ls | grep -v "lost+found" | xargs rm -rf --
rm lost+found 2>/dev/null
# DSDe443580 : End :
fi
cd $orig_dir

with something like:

orig_dir="/" # we start out at '/' (root)
for cldir in "/tmp /var/tmp"
do
cd /$cldir
if [ $? -ne 0 ]; then
echo "ERROR: could not change to directory <$cldir>"
echo "ERROR: no cleaning done"
rval=1
else
echo "NOTE: Clearing files from $cldir"
# ll |grep "^d.*"|awk '{print $9}'|grep -v "lost+found"|xargs rm -rf
#
# fix for DSDe443580: Begin :
# /sbin/init.d/clean_tmps script fails with large numbers of files in the
# /tmp directory.
# rm command was failing because the argument list was greater than ARG_MAX.
# xargs(1) is used to limit the argument size of rm to ARG_MAX.
#
# Fix for Defect JAGab68614 : Bad Patch PHCO_15932
# clean_tmps script will fail if the /tmp directory contains -name file types.
# "rm -rf" is changed to "rm -rf --"
ls | grep -v "lost+found" | xargs rm -rf --
rm lost+found 2>/dev/null
# DSDe443580 : End :
fi
cd $orig_dir
done

Note that each patch upgrade will possibly
overwrite /sbin/init.d/clean_tmps so
you need to save the customized copy of
the file...

Cheers,

Dusan
VK2COT - Dusan Baljevic
Christina Martin
Frequent Advisor

Re: clean_tmps for /tmp and /var/tmp

response to:
Feb 10, 2008 20:17:38 GMT points for answer: Unassigned 10 9 8 7 6 5 4 3 2 1 0

--------------------------------------------------------------------------------
hi crstiana,

if you look at clean_tmps script it does not clean /var/tmp directoy . it just clean /tmp and list files in /var/tmp

Hasan




yes, it lists the files in /var/tmp. However it doesn't clean it.

cleaning of /tmp is pretty consistent, but doesn't always happen.
Christina Martin
Frequent Advisor

Re: clean_tmps for /tmp and /var/tmp

response to:

Hello,

You obviously run HP-UX 11.1 or 11.23.
They are not designed to automate
cleanup of /var/tmp at boot time.
/etc/rc.config.d/clean_tmps was
only meant for cleaning up /tmp.




Thank you,
we'll give this a shot today and see what happens... .

I'll get back to you in a couple hours!

Lisa
Christina Martin
Frequent Advisor

Re: clean_tmps for /tmp and /var/tmp

okay here is what our cleantmps looks like:

#
# Process CLEAR_TMP flag
#
if [ "$CLEAR_TMP" -eq 0 ]; then
rval=2 # We did not do anything
else
orig_dir="/" # we start out at '/' (root)
cd /tmp
if [ $? -ne 0 ]; then
echo "ERROR: could not change to directory "
echo "ERROR: no cleaning done"
rval=1
else
echo "NOTE: Clearing files from /tmp"
# Modified by CSED to remove file beginning with dot (ex: .dt)
rm -rf .??* !(lost+found)
fi
# The following lines were added to clear "/var/tmp"
cd /var/tmp
if [ $? -ne 0 ]; then
echo "ERROR: could not change to directory "
echo "ERROR: no cleaning done"
rval=1
else
echo "NOTE: Clearing files from /var/tmp"
rm -rf .??*
fi
# The above lines were added to clear "/var/tmp"
cd $orig_dir
fi

#
# Process LIST_TEMPS flag
#
if [ "$LIST_TEMPS" -eq 0 ]; then
rval=2 # We did not do anything
else
for dir in /tmp /var/tmp /lost+found
do
if [ -d "$dir" ]; then
if [ "$(ls -A $dir)" ]; then
echo "NOTE: Files in $dir:"
ls -lA $dir
fi
fi
done
fi
;;
*)
echo "usage: $0 {start}"
rval=1
;;
esac

exit $rval

James R. Ferguson
Acclaimed Contributor

Re: clean_tmps for /tmp and /var/tmp

Hi (again) Christina"

Once again, what does your '/etc/rc.log' have in the way of messages from your 'clean_tmps' ?

Regards!

...JRF...
F Verschuren
Esteemed Contributor

Re: clean_tmps for /tmp and /var/tmp

hi,

your rm command:
rm .??* will trow only away files starting thit a dot and that adleast two carracters
If you put in a secend line whitout the . it will clear the other files