Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] r45615: Read the program name rather than hardcoding it

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 17 Oct 2012 23:10:34 -0700
On Oct 17, 2012, at 2:22 PM, Anders Broman <a.broman@xxxxxxxxxxxx> wrote:

> Guy Harris skrev 2012-10-17 22:13:
>> On Oct 17, 2012, at 12:35 PM, Anders Broman <a.broman@xxxxxxxxxxxx> wrote:
>> 
>>> One use case is a internal version which would be nice to be able to install co-existing with a
>>> release version with separate profiles and preferences. Having a different program name makes it clearer
>>> that it *is* a internal version.
>> ...but what's different about it isn't its name, what's different about it is the version.
> ?
> The the dissectors would be different...

...but that's not a function of the *name*, it's, again, a function of the *version*.

> On windows the program installation dir, short cuts, registry entries and installer "paths" contains the name Wireshark if you do multiple installations of Wireshark by defining different installation dirs application
> data would still be shared and uninstalling one version might rip the personal settings etc out - that might be considered a bug.

The personal settings are in your "profile" directory, not in the installation directory; as far as I know, the NSIS uninstaller doesn't know about them and won't remove them.

> On Windows if you want to run the command line tools you would have to run the from the program dir so in this case having different "program" names would leave you with two independent installations including personal settings.

If you want to run the command line tools *or* Wireshark, you would have to "run them from the program dir" in that the executable image would be in \$translate("Program Files")\$PACKAGE_NAME; you don't have to "run them from the program dir" in the sense of having to cd to \$translate("Program Files")\$PACKAGE_NAME and run .\$PROGRAM_NAME.exe.

If the "program" name is $PACKAGE_NAME ("Wireshark" by default), then the name isn't dependent on which program you're running - but it *also* isn't what g_get_prgname() returns.  g_get_prgname() returns "the last component of argv[0]", which, at least on UN*X, would be $PROGRAM_NAME, and would, I think, be $PROGRAM_NAME.exe on Windows - meaning that

	1) it would *not* change if $PACKAGE_NAME changed

and

	2) it would be different for Wireshark ("wireshark.exe") and TShark ("tshark.exe")

so it would be *doubly* wrong if the intent is to have multiple packages of Wireshark installed.

If the intent *on Windows* is to have it be the "package name", then you'd have to grab the full absolute pathname of the executable image (which we already do) and extract the next-to-last component.

That might have surprising, and undesired, effects if you're running from the build directory, however.

It also doesn't necessarily help on UN*X.  In OS X, you could perhaps look at the pathname of the app bundle and extract $PACKAGE_NAME from the $PACKAGE_NAME.app component.  If Wireshark is installed as a bundle under something such as /opt, you might be able to extract the component after /opt; if, however, it's installed in /usr/bin or /usr/local/bin or /usr/X11/bin or something such as that, you might be out of luck.

> So running Tshark etc from the program dir of programname1 vs  programname2 would give the desired result I think.

If "programname1" and "programname2" are $PACKAGE_NAME, then that'd work *if* you actually extract $PACKAGE_NAME.  If that's the case, though, the same applies to Wireshark, so...

> So on windows the name of the cli tools can be the same in program name1 and program name 2.

...it's not an issue of "CLI tools" vs. Wireshark.

> But to cover all cases would we like to be able to configure the name of tshark wireshark and the personal settings dir?

Again, if the intent would be to have, for example, \Program Files\Wireshark and \Program Files\Special Local Wireshark, you're not configuring the names of TShark and Wireshark, you're configuring the directory in which they're installed - \Program Files\$PACKAGE_NAME\tshark.exe and \Program Files\$PACKAGE_NAME\wireshark.exe.

*If* the expectation is that preferences would *never* be shared between \Program Files\Wireshark\{tshark,wireshark,...}.exe and \Program Files\Special Local Wireshark\{tshark,wireshark,...}.exe, *then* using the next-to-the-last component of the executable image pathname as the directory name, relative to the profile directory, of the preferences directory would work.

However, if that's not the case, you'd want to separately configure $PACKAGE_NAME and the preferences directory name.