Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-25 Thread Peter Pentchev
On Wed, Jan 25, 2017 at 10:13:13AM +0100, Bastian Blank wrote:
> On Tue, Jan 24, 2017 at 05:19:49PM +0200, Peter Pentchev wrote:
> > The rname utility invokes a specified program, passing a different name
> > instead of the name of the program executable.
> 
> You are searching for symbolic links?

Errr, I do believe there was something about ephemeral symbolic links
a couple of lines further down :)

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-25 Thread Bastian Blank
On Tue, Jan 24, 2017 at 05:19:49PM +0200, Peter Pentchev wrote:
> The rname utility invokes a specified program, passing a different name
> instead of the name of the program executable.

You are searching for symbolic links?

Bastian

-- 
"That unit is a woman."
"A mass of conflicting impulses."
-- Spock and Nomad, "The Changeling", stardate 3541.9



Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-25 Thread Peter Pentchev
On Wed, Jan 25, 2017 at 11:11:31AM +0300, Dmitry Bogatov wrote:
> 
> [2017-01-24 17:19] Peter Pentchev 
> >
> > Package: wnpp
> > Severity: wishlist
> > Owner: Peter Pentchev 
> >
> > * Package name: rname
> >   Version : 1.0.2
> >   Upstream Author : Peter Pentchev 
> > * URL : https://devel.ringlet.net/sysutils/rname/
> > * License : BSD-2-clause
> >   Programming Lang: C
> >   Description : invoke a program under a different name
> >
> > The rname utility invokes a specified program, passing a different name
> > instead of the name of the program executable.  This could be useful in
> > a number of cases, both during software development, testing, and in
> > production use.  There are many programs that do different things based
> > on what name they have been invoked under; the rname utility avoids
> > the need to e.g. create ephemeral symlinks to run these programs in
> > some conditions when they have not been completely installed.
> >
> > I originally wrote this tool in 2000 and I'm resurrecting it now for
> > the purpose of writing unit and integration tests for just such
> > a multifaceted program.
> 
> One more argv0 implementation? I know at least two:
> 
> $ dpkg -S argv0
> ucspi-tcp: /usr/bin/argv0
> [...]
> $ dpkg -S chpst
> runit: /usr/bin/chpst
> [...]
> 
> Probably, there is already a lot.

OK, so this is embarrassing :)  The rname webpage even refers to
ucspi-tcp as the reason I wrote this back in 2000; guess I didn't
notice argv0 there even then :/

Thanks for pointing this out!

And as for Christian and Josh's emails, yes, I should've mentioned
straight up front that I did indeed know about exec -a and I did
know that I can do this with Perl and Python.  However, for many
command-line tools that I write (and I've written quite a lot, even
though not all of them have seen the light of day), the test suite
is one of these three:
- a Perl t/*.t script using Test::Command
- a POSIX shell t/*.t script outputting TAP
- just a couple of lines in a Makefile's "test" target

Of these, only Test::Command looks like it might be possible to be
extended in a sensible way.  Of course, the other two may go for
"bash required, it's available almost everywhere anyway", but I do
tend to steer clear of this point of view (long-time FreeBSD user
and, once upon a time, committer; also more hours than I like to
remember invested in former jobs herding Solaris and HP/UX boxes...).

However, since there is already an argv0 in uscpi-tcp (argh!),
I'm closing this.  Thanks for all the responses!

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-25 Thread Dmitry Bogatov

[2017-01-24 17:19] Peter Pentchev 
>
> part 1 text/plain1214
> Package: wnpp
> Severity: wishlist
> Owner: Peter Pentchev 
>
> * Package name: rname
>   Version : 1.0.2
>   Upstream Author : Peter Pentchev 
> * URL : https://devel.ringlet.net/sysutils/rname/
> * License : BSD-2-clause
>   Programming Lang: C
>   Description : invoke a program under a different name
>
> The rname utility invokes a specified program, passing a different name
> instead of the name of the program executable.  This could be useful in
> a number of cases, both during software development, testing, and in
> production use.  There are many programs that do different things based
> on what name they have been invoked under; the rname utility avoids
> the need to e.g. create ephemeral symlinks to run these programs in
> some conditions when they have not been completely installed.
>
> I originally wrote this tool in 2000 and I'm resurrecting it now for
> the purpose of writing unit and integration tests for just such
> a multifaceted program.

One more argv0 implementation? I know at least two:

$ dpkg -S argv0
ucspi-tcp: /usr/bin/argv0
[...]
$ dpkg -S chpst
runit: /usr/bin/chpst
[...]

Probably, there is already a lot.

-- 
X-Web-Site: https://sinsekvu.github.io | Note that I process my email in batch,
Accept-Languages: eo,ru,en | at most once every 24 hours. If matter
Accept: text/plain, text/x-diff| is urgent, you have my phone number.


pgpKwjuwtXsKj.pgp
Description: PGP signature


Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-24 Thread Clint Adams
On Tue, Jan 24, 2017 at 05:24:37PM +0100, Christian Seiler wrote:
> (The shell needs to be bash, mksh, zsh or similar to work; dash and
> others don't support -a for exec.)

In zsh you can just use the built-in functionality, f.ex.

ARGV0=arp busybox



Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-24 Thread Andrey Rahmatullin
On Tue, Jan 24, 2017 at 05:24:37PM +0100, Christian Seiler wrote:
> This is definitely useful (I've needed this myself at multiple times),
> but wouldn't it be better if this were part of coreutils or util-linux
> or something similar?
That's what Openwall does.
http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/coreutils/runas.c

-- 
WBR, wRAR


signature.asc
Description: PGP signature


Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-24 Thread Josh Triplett
On Tue, 24 Jan 2017 17:19:49 +0200 Peter Pentchev  wrote:
> The rname utility invokes a specified program, passing a different name
> instead of the name of the program executable.  This could be useful in
> a number of cases, both during software development, testing, and in
> production use.  There are many programs that do different things based
> on what name they have been invoked under; the rname utility avoids
> the need to e.g. create ephemeral symlinks to run these programs in
> some conditions when they have not been completely installed.
> 
> I originally wrote this tool in 2000 and I'm resurrecting it now for
> the purpose of writing unit and integration tests for just such
> a multifaceted program.

What kind of test environment do you plan to use rname from?  Not trying
to suggest that you shouldn't package it, but I wanted to call attention
to a little-known feature of the bash exec builtin:

~$ (exec sh -c 'echo $0')
sh
~$ (exec -a differentname sh -c 'echo $0')
differentname

That unfortunately doesn't work in portable sh, though; rname seems like
an appropriate option if you can more easily require rname than
requiring bash (or a better scripting/testing language).

- Josh Triplett



Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-24 Thread Christian Seiler
On 01/24/2017 04:19 PM, Peter Pentchev wrote:
> Package: wnpp
> Severity: wishlist
> Owner: Peter Pentchev 
> 
> * Package name: rname
>   Version : 1.0.2
>   Upstream Author : Peter Pentchev 
> * URL : https://devel.ringlet.net/sysutils/rname/
> * License : BSD-2-clause
>   Programming Lang: C
>   Description : invoke a program under a different name
> 
> The rname utility invokes a specified program, passing a different name
> instead of the name of the program executable.  This could be useful in
> a number of cases, both during software development, testing, and in
> production use.  There are many programs that do different things based
> on what name they have been invoked under; the rname utility avoids
> the need to e.g. create ephemeral symlinks to run these programs in
> some conditions when they have not been completely installed.
> 
> I originally wrote this tool in 2000 and I'm resurrecting it now for
> the purpose of writing unit and integration tests for just such
> a multifaceted program.

This is definitely useful (I've needed this myself at multiple times),
but wouldn't it be better if this were part of coreutils or util-linux
or something similar?

Because say if I wanted to use that functionality in a package of mine
(for unit tests or similar), I'd probably not want to depend on a tiny
package just for this, especially since there are ways of doing the
very same thing with packages that are installed on most systems:

/bin/bash -c "exec -a $argv0 $progname $args"
perl -e 'exec {shift} @ARGV' $progname $argv0 $args
python3 -c 'import os, sys; os.execvp(sys.argv[1], sys.argv[2:])' \
$progname $argv0 $args

(The shell needs to be bash, mksh, zsh or similar to work; dash and
others don't support -a for exec.)

I would prefer a standalone program for this of course, but the pain
of the other solutions is not large enough for me that the trade-off
in depending on something non-standard makes sense to me.

Of course that's just my personal assessment, YMMV, and I'm not
opposed to you packaging this (what you provide is definitely useful),
but maybe this email gives you some food for thought about how to
best provide this functionality.

Regards,
Christian



Bug#852451: ITP: rname -- invoke a program under a different name

2017-01-24 Thread Peter Pentchev
Package: wnpp
Severity: wishlist
Owner: Peter Pentchev 

* Package name: rname
  Version : 1.0.2
  Upstream Author : Peter Pentchev 
* URL : https://devel.ringlet.net/sysutils/rname/
* License : BSD-2-clause
  Programming Lang: C
  Description : invoke a program under a different name

The rname utility invokes a specified program, passing a different name
instead of the name of the program executable.  This could be useful in
a number of cases, both during software development, testing, and in
production use.  There are many programs that do different things based
on what name they have been invoked under; the rname utility avoids
the need to e.g. create ephemeral symlinks to run these programs in
some conditions when they have not been completely installed.

I originally wrote this tool in 2000 and I'm resurrecting it now for
the purpose of writing unit and integration tests for just such
a multifaceted program.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature