HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Weird behavior in cp -p
Operating System - HP-UX
1830308
Members
2560
Online
110000
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 09:20 AM
01-20-2004 09:20 AM
Weird behavior in cp -p
Non-root users are able to create files owned by root. I am able to reproduce this on another HP-UX system, but not on Linux, BSD or Solaris.
$ uname -a
HP-UX Impala B.11.11 U 9000/800 1982107816 unlimited-user license
$ id
uid=1025(sos) gid=4(adm)
$ ls -l /sbin/init.d/tsm_client
-rwxr--r-- 1 root sys 3414 Dec 9 09:51 /sbin/init.d/tsm_client
$ cp -p /sbin/init.d/tsm_client .
$ ls -l tsm_client
-rwxr--r-- 1 root sys 3414 Dec 9 09:51 tsm_client
$ uname -a
HP-UX Impala B.11.11 U 9000/800 1982107816 unlimited-user license
$ id
uid=1025(sos) gid=4(adm)
$ ls -l /sbin/init.d/tsm_client
-rwxr--r-- 1 root sys 3414 Dec 9 09:51 /sbin/init.d/tsm_client
$ cp -p /sbin/init.d/tsm_client .
$ ls -l tsm_client
-rwxr--r-- 1 root sys 3414 Dec 9 09:51 tsm_client
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 09:27 AM
01-20-2004 09:27 AM
Re: Weird behavior in cp -p
This isn't altogether unexpected.
The normal behavior of '-p' is to preserve permissions when copying a file.
You could also reproduce this manually.
As a normal user you can do:
$ touch afile2
$ ll afile2
-rw-r--r-- 1 wallekp users 0 Jan 20 16:24 afile2
$ chmod 744 afile2
$ ll afile2
-rwxr--r-- 1 wallekp users 0 Jan 20 16:24 afile2
$ chown root:sys afile2
$ ll afile2
-rwxr--r-- 1 root sys 0 Jan 20 16:24 afile2
But once you change the ownership of the file to someone other than yourself, you can't do anything else as shown below.
$ chown wallekp afile2
afile2: Not owner
The normal behavior of '-p' is to preserve permissions when copying a file.
You could also reproduce this manually.
As a normal user you can do:
$ touch afile2
$ ll afile2
-rw-r--r-- 1 wallekp users 0 Jan 20 16:24 afile2
$ chmod 744 afile2
$ ll afile2
-rwxr--r-- 1 wallekp users 0 Jan 20 16:24 afile2
$ chown root:sys afile2
$ ll afile2
-rwxr--r-- 1 root sys 0 Jan 20 16:24 afile2
But once you change the ownership of the file to someone other than yourself, you can't do anything else as shown below.
$ chown wallekp afile2
afile2: Not owner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 09:30 AM
01-20-2004 09:30 AM
Re: Weird behavior in cp -p
If you do a man cp, you will find that -p preserves mtime, atime, mode, uid, and gid as allowed by permissions. This is normal behavior. However, the dangerous mode bits (setuid, setgid, sticky-bit) are not preserved and are automatically cleared on the copy.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2004 10:03 AM
01-20-2004 10:03 AM
Re: Weird behavior in cp -p
As I recall, the ability to hand off your files to another user is one of the historical differences between SysV(R4) and Berkeley. *BSD is obviously Berkeley-based. SunOS/Solaris 1.X was. I suspect Linux is but don't really know.
I also seem to recall you can change HP-UX chown behavior with (I think) the setprivgrp command ("CHOWN" priv; have to edit a boot script to make it global/"permanent"). Don't know what it does, if anything, to cp behavior.
Mic
I also seem to recall you can change HP-UX chown behavior with (I think) the setprivgrp command ("CHOWN" priv; have to edit a boot script to make it global/"permanent"). Don't know what it does, if anything, to cp behavior.
Mic
What kind of a name is 'Wolverine'?
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP