It is currently Mon, 25 Sep 2023 11:26:38 GMT



 
Author Message
 how to set argv command line args for ps
[SunOS 5.8 Generic_117350-06]

I would like to write a C program (actually a library module for
python, but that's not important here) which changes it's argv, i.e.
which changes the
way it's arguments are shown by the "ps" command.  When my application
loads
a new top-level data object, I want the data's name to show in the "ps"
listing.

This works easily under linux:

 #include <unistd.h>
 #include <string.h>
 main(int argc, char **argv) {
    strcpy(argv[1], "XXX");
    sleep(120);  /* go and look at "ps" output */
 }

gcc -o mytest mytest.c
./mytest aaaa bb &

ps -o args 4391
COMMAND
./mytest XXX  bb

How can I do this under solaris?

--- George



 Wed, 09 Apr 2008 01:23:00 GMT   
 how to set argv command line args for ps

You can't, except when you use /usr//ucb/ps to look at the argument vector.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.



 Wed, 09 Apr 2008 01:52:26 GMT   
 how to set argv command line args for ps
In article <43592ada$0$11079$e4fe5...@news.xs4all.nl>,
        Casper H.S. Dik <Casper....@Sun.COM> writes:

Since sendmail is a program that modifies its args so you can tell what
each instance is doing, it makes a good example of this:

$ /usr/bin/ps -ef|grep sendmail|grep -v grep
   smmsp   533     1  0   Oct 15 ?        0:01 /usr/lib/sendmail -Ac -q15m
    root  1101     1  0   Oct 15 ?        0:15 /usr/lib/sendmail -bd -q15m
$

$ /usr/ucb/ps -auxww|grep sendmail|grep -v grep
smmsp      533  0.0  0.2 4456 1392 ?        S   Oct 15  0:01 sendmail: Queue runner@00:15:00 for /var/spool/clientmqueue
root      1101  0.0  0.3 4672 2408 ?        S   Oct 15  0:14 sendmail: accepting connections
$

This difference was quite intentional, 'way back (SVR2 at least, I think).
What /usr/bin/ps shows is (nowadays) pr_psargs from the psinfo struct
(used to be a field of struct user back in ancient history days, on some
flavors of Unix); that's effectively a snapshot of the 1st 80 characters
of the args at exec time, concatenated and separated by spaces.  There are
two advantages to that:

* it's much easier and faster to retrieve than digging out the individual
  args, which involves looking in the process's address space; with
  structured /proc, it also requires no special privileges, while digging
  the possibly modified args requires euid same as the target process, or
  root.  (it used to be even more complicated back before /proc - one
  might have to dig into either memory or swap to find them)

* it prevents a process from concealing itself by changing that aspect of
  its appearance.  Of course, there are still other ways to hide...

and of course one disadvantage:

* the effort that some programs (like sendmail) make to use their args as
  a way of showing their status is wasted

But on current Solaris, as Casper said (and the above example shows),
you have a choice, depending on which version of ps you use.  Note: IIRC,
some very old versions of Solaris (somewhere <= 2.4, I think) might not
have had /usr/ucb/ps able to dig out modified args or environment
variables.

--
mailto:rlha...@smart.net  http://www.smart.net/~rlhamil

Lasik/PRK theme music:
    "In the Hall of the Mountain King", from "Peer Gynt"



 Thu, 10 Apr 2008 06:27:10 GMT   
 how to set argv command line args for ps
Richard.L.Hamil...@mindwarp.smart.net (Richard L. Hamilton) writes:

And:

* it's not possible when a process unintentionally modifies its enviroment
  or argument vector to reveal private data.

In S10, you'll only be able to do that on processes you can control.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.



 Thu, 10 Apr 2008 17:40:42 GMT   
 how to set argv command line args for ps
In article <435b5a9a$0$11065$e4fe5...@news.xs4all.nl>,
        Casper H.S. Dik <Casper....@Sun.COM> writes:

Which nicely addresses the point you raised.

Still, command line args (either way), as well as a number of other things
(file names, contents) _could_ be used to do evil things to root (or a
user eligible to see the data), if it was using a terminal on which escape
sequences could set and then report back strings.  Of course that's
nothing peculiar to ps.

--
mailto:rlha...@smart.net  http://www.smart.net/~rlhamil

Lasik/PRK theme music:
    "In the Hall of the Mountain King", from "Peer Gynt"



 Fri, 11 Apr 2008 09:38:03 GMT   
 how to set argv command line args for ps
Richard.L.Hamil...@mindwarp.smart.net (Richard L. Hamilton) writes:

Quite; that's why you shouldn't be using terminals with programmable
answerback sequences.

And the people who fixed "xterm should be able to report windowtitle"
in some versions of xterm have introduced a security probolem because of it.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.



 Fri, 11 Apr 2008 17:35:49 GMT   
 how to set argv command line args for ps
Casper H.S. Dik <Casper....@sun.com> wrote:

more to the point: people who live in glass houses shouldn't throw bricks.

hmm - you've done nothing about dtterm, right?

--
Thomas E.{*filter*}ey
http://www.**-**.com/
ftp://invisible-island.net



 Fri, 11 Apr 2008 19:05:25 GMT   
 how to set argv command line args for ps
In article <11lpfvlabvra...@corp.supernews.com>,
        Thomas{*filter*}ey <dic...@saltmine.radix.net> writes:

For a 'bot that jumps on every mention of xterm (or is it just in c.u.s?),
he's got a point.  From dtterm(5):

        Esc [ p1 ; p2 ; p3 t
                Window manipulation.  Valid values  for  p1  (and
                any additional parameters) are:
[...]
                   20    Report  the  dtterm(1)   window's   icon
                         label.   The  terminal  emulator returns
                         ``Esc ] L label Esc Backslash''.

                   21    Report  the  dtterm(1)  window's  title.
                         The  terminal emulator returns ``Esc ] l
                         title Esc Backslash''.

--
mailto:rlha...@smart.net   http://www.**-**.com/ ~rlhamil

Lasik/PRK theme music:
    "In the Hall of the Mountain King", from "Peer Gynt"



 Sat, 12 Apr 2008 04:44:12 GMT   
 how to set argv command line args for ps
Richard L. Hamilton <Richard.L.Hamil...@mindwarp.smart.net> wrote:

well, as noted, Casper has two sets of standards - one for Sun and another
for others.  We've been here before.  See

http://www.**-**.com/

(looking forward to Casper's announcement of an updated dtterm ;-)

--
Thomas E.{*filter*}ey
http://www.**-**.com/
ftp://invisible-island.net



 Sat, 12 Apr 2008 05:14:13 GMT   
 how to set argv command line args for ps
In article <11lqjl59pjta...@corp.supernews.com>,
Thomas{*filter*}ey  <dic...@saltmine.radix.net> wrote:

Is there an RFE for making answerback an option feature?
<URL: http://www.**-**.com/ %40nl-usenet.sun...>

John
groenv...@acm.org



 Sat, 12 Apr 2008 09:17:15 GMT   
 how to set argv command line args for ps
groen...@cse.psu.edu (John D Groenveld) writes in comp.unix.solaris:
|In article <11lqjl59pjta...@corp.supernews.com>,
|Thomas{*filter*}ey  <dic...@saltmine.radix.net> wrote:
|> http://www.**-**.com/
|>
|>(looking forward to Casper's announcement of an updated dtterm ;-)
|
|Is there an RFE for making answerback an option feature?

RFE's against dtterm are unlikely to go anywhere.   CDE is pretty much
in sustaining mode, with minimal enhancements being made, and dtterm is
no exception.   (dtlogin is the biggest exception, since it's still the
default login system for both CDE & GNOME.)

--
________________________________________________________________________
Alan Coopersmith * al...@alum.calberkeley.org * Alan.Coopersm...@Sun.COM
  http://www.**-**.com/ ~alanc/   *   http://www.**-**.com/
  Working for, but definitely not speaking for, Sun Microsystems, Inc.



 Sat, 12 Apr 2008 11:25:52 GMT   
 how to set argv command line args for ps

Oh yeah. I KNEW there was a reason you were killfiled.



 Sat, 12 Apr 2008 11:27:57 GMT   
 how to set argv command line args for ps
In article <djk8k0$ud...@agate.berkeley.edu>,
Alan Coopersmith  <al...@alum.calberkeley.org> wrote:

Understood. An RFE, for the record, might be useful to those customers
who can't or won't follow Sun down the rabbit hole on Sun's timetable.

Please let us know if you spot CDE EOL notice in docs.sun.com release
notes or where ever the new policy states such customer notifications
of lifecycle changes should go.

John
groenv...@acm.org



 Sat, 12 Apr 2008 12:39:22 GMT   
 how to set argv command line args for ps
In article <vilain-C3BDE6.16243724102...@comcast.dca.giganews.com>,
Michael Vilain  <vil...@spamcop.net> wrote:

The risk for those of us who have entries like /Casper....@Sun.COM/f:T+
or /sun.com/f:T+ in our killfiles is that out of deference, we'll allow
those we respect to slip down the slippery slope of double standards
and the cesspool of bullshit.
Bad idea. [tm]

John
groenv...@acm.org



 Sat, 12 Apr 2008 13:11:16 GMT   
 how to set argv command line args for ps
groen...@cse.psu.edu (John D Groenveld) writes in comp.unix.solaris:
|Please let us know if you spot CDE EOL notice in docs.sun.com release
|notes or where ever the new policy states such customer notifications
|of lifecycle changes should go.

That's still the release notes.   I wouldn't be at all surprised to
see one there in the release notes for the release currently code-named
"Nevada."

--
________________________________________________________________________
Alan Coopersmith * al...@alum.calberkeley.org * Alan.Coopersm...@Sun.COM
 http://www.csua.berkeley.edu/~alanc/   *   http://blogs.sun.com/alanc/
  Working for, but definitely not speaking for, Sun Microsystems, Inc.



 Sat, 12 Apr 2008 14:40:16 GMT   
 
   [ 21 post ]  Go to page: [1] [2]

Similar Threads

1. CGI commands with command line args?

2. PS command, args truncated?

3. Question: command args using ps

4. access command line w/o argv?

5. How to find out all the input args of a long command line

6. Script/Command line args for FTP needed!!

7. How to hide command line args under Solaris

8. Command-line args in C

9. Command line args

10. command line args and 'if'


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software