Operating System - HP-UX
1829608 Members
1333 Online
109992 Solutions
New Discussion

Disable Copyright text when using command su -

 
SOLVED
Go to solution
boje
Regular Advisor

Disable Copyright text when using command su -

Hi!

Does anyone know how i can disable the copyright text that appears when i use the command su - ?
The text i mean is this one:
(c)Copyright 1983-2003 Hewlett-Packard Development Company, L.P.
(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of California
(c)Copyright 1980, 1984, 1986 Novell, Inc.
(c)Copyright 1986-2000 Sun Microsystems, Inc.
(c)Copyright 1985, 1986, 1988 Massachusetts Institute of Technology
(c)Copyright 1989-1993 The Open Software Foundation, Inc.
(c)Copyright 1990 Motorola, Inc.
(c)Copyright 1990, 1991, 1992 Cornell University
(c)Copyright 1989-1991 The University of Maryland
(c)Copyright 1988 Carnegie Mellon University
(c)Copyright 1991-2003 Mentat Inc.
(c)Copyright 1996 Morning Star Technologies, Inc.
(c)Copyright 1996 Progressive Systems, Inc.


RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the U.S. Government is subject to
restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
Technical Data and Computer Software clause in DFARS 252.227-7013.


Hewlett-Packard Company
3000 Hanover Street
Palo Alto, CA 94304 U.S.A.

Rights for non-DOD U.S. Government Departments and Agencies are as set
forth in FAR 52.227-19(c)(1,2).

Value of TERM has been set to "xterm".
WARNING: YOU ARE SUPERUSER !!

Br
Patrik
10 REPLIES 10
Torsten.
Acclaimed Contributor

Re: Disable Copyright text when using command su -

See this discussion:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1230173

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
boje
Regular Advisor

Re: Disable Copyright text when using command su -

Hi!

Thank you for the link to the other post. I did search but did not find it.
I know now that it is illegal to remove this copyright notice. But i think it is a stupid way to show it. When using su - command i scripts, the log starts filling up with these messages: ttytype: couldn't open /dev/tty for reading
stty: : Not a typewriter

Followed by the whole copyright text.

Br
Patrik
Anshumali
Esteemed Contributor

Re: Disable Copyright text when using command su -

Patric,

Its perfectly legal to have it like below.

1. Copy the file /etc/copyright to /etc/copyright.txt
2. Modify the file /etc/copyright to contain the following text (only): This server software is copyright (C) HP and others. To view the entire copyright notice, use cat /etc/copyright.txt

This will save large text for you...

This was verified with the HP legal department and confirmed it
complies with the legal requirement. If you have access to KB's, there is a doc for this.
Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!
BUPA IS
Respected Contributor

Re: Disable Copyright text when using command su -

Hello Patrik

does adding this to /etc/profile help ?
(make a copy sign on in two places to test etc. )
It should only display it if is on a proper pty

tty -s
if [ $? = 0 ]

then
cat /etc/copyright
fi
Mike
Help is out there always!!!!!
boje
Regular Advisor

Re: Disable Copyright text when using command su -

Hi!

I do not understand what this thing does:

tty -s
if [ $? = 0 ]

then
cat /etc/copyright
fi

If i run a script in crontab, it will not show copyright info?

Br
Patrik
Oviwan
Honored Contributor
Solution

Re: Disable Copyright text when using command su -

if crontab is your only problem, then you can redirect the stdout and stderr to /dev/null, like this:

* * * * * /path/to/script.sh >/dev/null 2>&1
BUPA IS
Respected Contributor

Re: Disable Copyright text when using command su -

Hello Patrik,
The tty command prints the name of the terminal device you are connected to.
It gives a return code of 0 if it is a terminal.
If it is not you get a return code of 1, and a 2 if there is some error.
So the code checks if you are on a terminal and then prints the notice otherwise it does not bother .
The -s option supresses the terminal name output so that you can use it in a test without getting any output.

$? is the standard environment variable for the return code of the last command.

See man tty for details.

Mike



Help is out there always!!!!!
Dennis Handly
Acclaimed Contributor

Re: Disable Copyright text when using command su -

>BUPA IS: if [ $? = 0 ]

The proper syntax is: if [ $? -eq 0 ]
That way it does integer comparisons.

You can also skip tty(1) and just use: if [ -t ]
Bill Hassell
Honored Contributor

Re: Disable Copyright text when using command su -

> the log starts filling up with these messages: ttytype: couldn't open /dev/tty for reading stty: : Not a typewriter

This message and the copyright message are designed only to be read by people. As mentioned before, you must protect your login profiles, both /etc/profile and $HOME/.profile. A script, whether in cron or batch is not connected to a terminal and therefore, no human is there to read or respond to any messages. You must gather *ALL* the terminal commands including the copyright message (and the /etc/motd message if used) into a single part of your profiles, then run these commands when a real terminal exists. Examples of terminal-only commands:

ttytype
tset
tput
stty
tabs

and anything that is designed for humans to read such as:

cat /etc/copyright
cat /etc/motd

I am not a lawyer, but I believe that it is not illegal to bypass this /etc/copyright as long as you see the message when the system first starts up, something like the first pages of a book. Another method is to use the notice given in many books and documents, something like this:

print "To read the copyright statement"
print "type this command: cat /etc/copyright"

But much more important than the copyright message is proper execution of the su - command in cron or batch -- do not run any terminal-only commands under these circumstances.


Bill Hassell, sysadmin

Re: Disable Copyright text when using command su -

I'd go one step further than Bill and say that:

su - user -c "..."

Has no place in scripts at all. This instantly places a dependency in the script on the contents of /etc/profile and probably the users .profile, plus .kshrc or .cshrc if other shells are the default shell for a specific user. Thats not good as you don't always know what some other user is going to do with his startup script (for example some people put interactive menus in their login script).

If you need some env variables setting when calling a command as another user, its much better to explicitly set them first and then call su without the "-" which sources the users own environment. So for example a routine to start an Oracle database might go from the dangerous:

su - oracle -c "/usr/local/bin/dbstart"

Which calls everything in /etc/profile and ~oracle/.profile regardless of whether I want or need it, to the much safer and more reliable:

ORACLE_SID=mydb
ORACLE_HOME=/oracle/10.2
PATH=${PATH}:${ORACLE_HOME}/bin
su oracle -c "/usr/local/bin/dbstart"

Which only has the env variables set I know I need to start Oracle.

HTH

Duncan

I am an HPE Employee
Accept or Kudo