Operating System - HP-UX
1827612 Members
3046 Online
109966 Solutions
New Discussion

Re: How to create symbolic link permission of lr--r--r-T

 
SOLVED
Go to solution
Jack C. Mahaffey
Super Advisor

How to create symbolic link permission of lr--r--r-T

I want to reset the permission for the /etc/termcap file. Here's what it should look like.

lr--r--r-T 1 root sys 22 May 27 16:37 termcap -> /usr/share/lib/termcap

The last character 'T' is what I'm unsure of how to do it with the umask command.

I know umask 222 will give me lr--r--r-- when I create the link. What do I do for the T?

jack
23 REPLIES 23
Stefan Farrelly
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

Cor, tough one. I cant do it using chmod or umask. Easiest way to do it is tar up the symbolic link from another hp box, then untar it, that works!
Im from Palmerston North, New Zealand, but somehow ended up in London...
Stuart Abramson_2
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

Jack:

I don't know how to do a "T".

I can do a "t". that's something!


1. If you do an ll and you see:

-rwsr-sr-t 1 abramss adm 629 Jul 7 11:32 hpux_11.new_features
^ ^ ^
| | |____ Sticky bit
| |
| |_______ SGID bit
|
|__________ SUID bit

2. Here's how you set them:

chmod 1777 /tmp # Set sticky bit
chmod 2555 filename # Set SGID bit
chmod 4555 filename # Set SUID bit

3. Here's what they mean:

a. Program File:

SUID: When a user executes this program, his effective UID set to the
UID of the owner of the file. (mostly used with root owner.)

SGID: When a user executes this program, his effective GID becomes
the GID of the program GID.

Files created by this program, have their primary GID set to the
GID of the program.

Sticky: A program that has it's sticky bit set will not be removed from
swap space after the program has terminated. This means the
next guy can execute the same binary.


A. Clay Stephenson
Acclaimed Contributor

Re: How to create symbolic link permission of lr--r--r-T

The permissions on the symbolic link do not matter --- only those of the underlyling file.
The 'T' (Sticky Text Bit) is set using the 1000 octal value. e.g. chmod 1222 myfile.
If it ain't broke, I can fix that.
Jack C. Mahaffey
Super Advisor

Re: How to create symbolic link permission of lr--r--r-T

I only want to change the permission on the symbolic link. chmod will not work on a symbolic link. Running chmod on a symbolic link changes the permission of the underlying file.

Massimo Bianchi
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

Some light on t or T: i think that "t" is used when the file is executable, T when it's a simple data file:

riops002:/tmp/massimo/test/test> umask
022
riops002:/tmp/massimo/test/test> rm test
riops002:/tmp/massimo/test/test> touch test
riops002:/tmp/massimo/test/test> ll test
-rw-r--r-- 1 root sys 0 Sep 11 16:29 test
riops002:/tmp/massimo/test/test> chmod a+t test
riops002:/tmp/massimo/test/test> ll test
-rw-r--r-T 1 root sys 0 Sep 11 16:29 test
riops002:/tmp/massimo/test/test> chmod 755 test
riops002:/tmp/massimo/test/test> ll test
-rwxr-xr-x 1 root sys 0 Sep 11 16:29 test
riops002:/tmp/massimo/test/test> chmod a+t test
riops002:/tmp/massimo/test/test> ll test
-rwxr-xr-t 1 root sys 0 Sep 11 16:29 test
riops002:/tmp/massimo/test/test>



Don't know regarding the link, T or t ...

Massimo
Jack C. Mahaffey
Super Advisor

Re: How to create symbolic link permission of lr--r--r-T

I can quickly get the chmod settings by using a home grown utility I named getchmod.

Looks like I got some folks stumped.


Rodney Hills
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

Out of curiousity, why would you want to change the permissions on the symbolic link?

As was mentioned before, the permissions on the link itself have no relevance. And one would think you would want a "chmod 774 termcap" to be applied to the actual file.

-- Rod Hills
There be dragons...
Jack C. Mahaffey
Super Advisor

Re: How to create symbolic link permission of lr--r--r-T

I want two systems to have the same permission settings. The link mentioned is inconsistent between the systems. I could take the easy way out and tar the link but I want to know how to make the symbolic link.

jack
Mark Grant
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

I really think A Clay Stephenson shouldn't be ignored, i.e the permissions on a symbolic link do not matter.

The only way you can change the permissions on a symbolic link are to change your umask before you create it.

Nice problem though
Never preceed any demonstration with anything more predictive than "watch this"
Jack C. Mahaffey
Super Advisor

Re: How to create symbolic link permission of lr--r--r-T

Mark, I'm not ignoring any responses. Just want to know how to create the link. I appreciate all responses. Hope nothing taken the wron way.

jack...
Mark Grant
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

Jack,

Sorry, didn't mean to imply anybody was really being ignored, it's just my perculiar type of English I guess :)

Still, I really would be surprised if these permissions can be achieved on the link without a little bit of C and some inode mangling magic.

Never preceed any demonstration with anything more predictive than "watch this"
Steven Gillard_2
Honored Contributor
Solution

Re: How to create symbolic link permission of lr--r--r-T

Looks like it could be something to do with signifying the link as a "transition link":

# rm /etc/termcap
# tlinstall
NOTE: tlinstall is searching filesystem - please be patient
NOTE: Successfully completed
# ll /etc/termcap
lr--r--r-T 1 root sys 22 Sep 11 15:46 /etc/termcap -> /usr/share/lib/termcap

See man tlinstall for more info.

A "tusc" of the tlinstall command reveals it uses the lchmod() system call to set the mode:

lchmod("/etc/termcap", 0101444) ............................... = 0

This system call is undocumented (ie no man page), but its easy to write a C program that can use it.

Regards,
Steve
Helen French
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

From 'man umask': " Note that the file creation mode mask does not affect the set-user-id, set-group-id, or "sticky" bits."

The permission "T" (sticky bit set without "execute" permission for "others") can be set only with chmod command. Since you cannot set it on symbolic links, the best way is to tar and untar the file.
Life is a promise, fulfill it!
hein coulier
Frequent Advisor

Re: How to create symbolic link permission of lr--r--r-T

perhaps you can copy the link from one system to the other with tar ?
Stefan Farrelly
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

Jack,

I dont believe you can do it. Certainly not easily anyway. Umask wont allow it, chmod wont allow it (binary or C call). Ive tried all sorts of C calls to create, modify, open, write files and none will do it. C ignores the symlink also - goes straight to its destination.

I think youre going to have to bite the bullet and do it the hard way and tar it over from another server.

Now, if I had assembler for HP-UX and I could recall how to do it I think it would be possible!

It would certainly be interesting though to find out how HP created it in the first place.
/etc/termcap is not listed under swlist -l file which means its not on the source, but its created at some point by some program. Any ideas anyone which program it is ? I think it must exist on a server.

Im from Palmerston North, New Zealand, but somehow ended up in London...
Patrick Wallek
Honored Contributor

Re: How to create symbolic link permission of lr--r--r-T

OK, I think I know what you can do.

The /etc/termcap link to /usr/share/lib/termcap is a 9.X to 10.X transition link.

If you execute the command:

# /opt/upgrade/bin/tllist

It will show a list of all transition links that have been installed on your system. You will notice that /etc/termcap is one of those.

If you really want to re-establish the link the way it should be you can probably use the tlinstall command.

To preview what tlinstall will do:

# /opt/upgrade/bin/tlinstall -p -v

To actually have tlinstall recreate the transition link (I believe it will only recreate what is not there):

# /opt/upgrade/bin/tlinstall -v -l

Note: As far as I know this is the ONLY way to (re)create /etc/termcap with the permissions that it should have. It can not be done with the regular chmod command. /etc/termcap is a special case.
Jack C. Mahaffey
Super Advisor

Re: How to create symbolic link permission of lr--r--r-T

Forgot about the &##! transision links.

Thanks to all for your help. Ran tlinstall and the link got recreated.


Nothing like a challenge to keep the minds going. :)

Jack...
A. Clay Stephenson
Acclaimed Contributor

Re: How to create symbolic link permission of lr--r--r-T

Well, boys and girls. It can be done and I'll learn you how HP does it. As has been noted, the system call chmod() follows the symbolic link and thus does not operate on the symbolic link directly. Similarly, the symlink() system call does not allow a mode argument so that don't work neither. However, there is an UNDOCUMENTED system call, lchmod(), that does operate directly on the symbolic link.

The attached code illutrates its use. I intentionally did this in K&R C so that even the bundled C compiler can handle it. Compile like this:

cc lchmod.c -o lchmod

Use it like this on an EXISTING symbolic link.

lchmod 1664 mysymlink1

NOTE: This guy only understands OCTAL permissions but you are free to make it smarter if you like.

Regards,
Clay
If it ain't broke, I can fix that.
Greg White
Frequent Advisor

Re: How to create symbolic link permission of lr--r--r-T

Hi,

I have been following this thread all day because it was so interesting and challenging. After reading Stefan's comments and repeating some of his attempts in C, I too was completely baffled. Then I saw our Clay's last answer and was amazed. I tried it and it worked! So Clay, how did you know about this secret and undocumented lchmod function? You must be using some inside HP connections to come up with that answer.

PS Jack, you need to give Clay 50 points for that answer because he really solved a mystery.

I love this place,
Greg


I know how to do it in pascal.
A. Clay Stephenson
Acclaimed Contributor

Re: How to create symbolic link permission of lr--r--r-T

No Greg, I didn't have no HP spies telling me what to do; it was just a bit of "a priori" reasoning. I knew that the tlinstall executable was able to set the sticky bit on soft links so now the question was how? You also have to understand that ultimately if there ain't a system call for it, UNIX can't do it --- so there had to be one. Now what was it? Well, I knew there were chown() and lchown() system calls and maybe, just maybe, there was an lchmod() to match the standard chmod() system call.

I then wrote a dummy program:
int main()
{
lchmod("dummy",0)
return(0);
}

It compiled and linked so the mystery system call had to exist.

-------------------------------------------

The other answer is that I am actually one of those whacko's who reads the man 2 pages (the system calls) and I may have seen lchmod() somewhere in another UNIX, far, far away ...

---- although I don't consciously remember it.

On the other hand, if them HP spies (or aliens) was good, maybe they implanted that bit of knowledge without me knowing nothing about it.

If it ain't broke, I can fix that.
Jack C. Mahaffey
Super Advisor

Re: How to create symbolic link permission of lr--r--r-T

Great stuff. I suspected noone wanted to lose sleep without a solution.

Thanks...
Greg White
Frequent Advisor

Re: How to create symbolic link permission of lr--r--r-T

Hi Clay,

Thanks for taking the time to answer my question. I just got in this morning and laughed when I read your answer.
I had to use Google to find out what "a priori" means. After I found out that it is a Latin phrase, I'm beginning to think that your use of terrible English grammar might be intentional. In any event, nobody doubts your knowledge of unix.

Jack, thanks for giving Clay the points. He earned them and made me laugh at the same time.

Regards,
Greg


I know how to do it in pascal.
A. Clay Stephenson
Acclaimed Contributor

Re: How to create symbolic link permission of lr--r--r-T

Hi Greg:

I just saw your last post and I assure you that I didn't go to say nothing terrible about your English grandma. I don't even know her.

At my 10th high school reunion (while I was teaching at a university; not, thankfully, English), I did make a special point to thank my English teacher for learning me to talk and write so good (that's nearly verbatim). I also pointed out that I used sentence diagramming and poetry analysis at least once per decade and thanked her for learning me them valuable skills too.


If it ain't broke, I can fix that.