Operating System - HP-UX
1752580 Members
5022 Online
108788 Solutions
New Discussion юеВ

DIRCMP kind of misleading

 
SOLVED
Go to solution
eric stewart_2
Advisor

DIRCMP kind of misleading

The question is what to do?
I ran a dircmp on a directory with 6 programs and all came back showing they were the same. Another user did the exact same dircmp and the results were that each program was different.
You ask why? I will tell you. The other user did not have permission to read the individual files.
DIRCMP did not give any indication of a read problem. The results were correct. What the user could read from the two directories were different.
What is your recommendations:
1. Ask for a change to the program?
2. Let the program be as is?
3. Some other ideas?
TIA
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: DIRCMP kind of misleading

As Forest Gump might say, "Dircmp is as dircmp does." It's just a shell script so change it to suit your needs. The fundamental problem with what you are requesting is that it would require dircmp to run as a setuid program. This is generally not a good thing to let a shell script do from a security standpoint.

The other thing to keep in mind is that dircmp can only compare text file; binary data will throw it a curveball. If you really want to do a comparison, you should build a utility around cksum. If the CRC's agree, the files are identical. You could make if fairly fancy by using the file command to determine if the file is a textfile and then run the diff command if you want the difflike output that dircmp can provide.
If it ain't broke, I can fix that.
eric stewart_2
Advisor

Re: DIRCMP kind of misleading

Thanks
That is all the info I need.
I will build into the script to check permissions of the files first.
You get all the points
eric stewart_2
Advisor

Re: DIRCMP kind of misleading

Here are the changes I made:
then cmp -s $D1/"$a" $D2/"$a"
>add RET=$?
>chg if [ $RET = 0 ]
then if [ "$Sflag" != "yes" ]
then echo "same $a"
fi
>add elif [ $RET != 1 ]
>add then if [ "$Sflag" != "yes" ]
>add then echo "unreadable $a"
>add fi
else echo "different $a"

Here is the output: I suggest HP make the change to dircmp. The cmp command has 2 as an unreadble return code for files.

Aug 15 19:25 2002 Comparison of dir1 dir2 Page 1


directory .
unreadable ./eric
doug hosking
Esteemed Contributor

Re: DIRCMP kind of misleading

Clay's comments about setuid shell scripts
are on target. They're evil from a security
standpoint. So evil, in fact, that future HP-UX releases (11.22 and later) will not support them by default.

It wouldn't make sense to make dircmp setuid
anyway. Doing this would effectively let any user read any file on the system!

I agree that silently skipping unreadable
files is non-intuitive. Making dircmp give
better error messages in this case seems
like the right thing to do. I have
submitted an enhancement request for
dircmp with HP.

eric stewart_2
Advisor

Re: DIRCMP kind of misleading

Thanks Doug
As you can see I did not change the setuid.
It was just a simple check of the return code that was already documented.
Thanks for submitting it to HP. I do not know the procedure for that ans appreciate it.