OpenSCAP / scap-workbench

SCAP Scanner And Tailoring Graphical User Interface
https://www.open-scap.org/tools/scap-workbench
GNU General Public License v3.0
226 stars 65 forks source link

Do not set application name #240

Closed jan-cerny closed 4 years ago

jan-cerny commented 4 years ago

We use QTemporaryFile to create temporary files. According to https://doc.qt.io/qt-5/qtemporaryfile.html, the default filename is determined from QCoreApplication::applicationName(). It returns "SCAP Workbench" which leads to creating temporary files with a space character in their name, eg. "/tmp/SCAP Workbench.XM8663". The space can cause problems with missing quotes s.a. the problems described in issue application name manually. Hopefully it will not cause any problem. If not set, the application name defaults to the executable name, which is scap-workbench. It doesn't affect the window title.

evgenyz commented 4 years ago

This change will affect the location of the config file. It used to store some settings for the remote connection, the directory and the time of usage of the last tailoring file. Instead of ~/.config/SCAP Workbench upstream it would be ~/.config/scap-workbench.

So there are three consequences:

Are we OK with this?

evgenyz commented 4 years ago

I'll correct myself. The directory name is coming from OrganizationName not ApplicationName. But still the config file name would be formed from ApplicationName. So /.config/SCAP Workbench upstream/SCAP Workbench.conf would become /.config/SCAP Workbench upstream/scap-workbench.conf.

We might also want to review the configuration naming policy as a whole.

P.S. I'd suggest changing OrganizationName to "OpenSCAP".

matejak commented 4 years ago

What I don't like about this solution is that somebody may re-introduce the application name for another reason. What about Andreas Bleischwitz's suggesstion?

The issue may be caused by using the default template of QTemporaryFile() which uses QCoreApplication::applicationName() suffixed by some arbitrary numbers:

QTemporaryFile::QTemporaryFile() Constructs a QTemporaryFile using as file template the application name returned by QCoreApplication::applicationName() (otherwise qt_temp) followed by ".XXXXXX". The file is stored in the system's temporary directory, QDir::tempPath().

In order to avoid those whitespaces QTemporaryFile() will need to get a suitable template as parameter or QTemporaryFile::setFileTemplate() to be initailized.

jan-cerny commented 4 years ago

@matejak That was my original idea, and as you already noticed I have originally proposed that in #240.

jan-cerny commented 4 years ago

@evgenyz I completely forgot about the config file. I don't think the config file is a documented feature, but it's nice. However, since spaces in file names require quoting, I would prefer if there are no spaces in the config file name as well.

evgenyz commented 4 years ago

@jan-cerny It is documented that applicationName property could be used in QSettings on certain conditions (https://doc.qt.io/qt-5/qcoreapplication.html#applicationName-prop), it's just not right away clear how it is used.

I don't like it that way too, and I don't like the organization name as well. But we should clean up or recycle old configuration in order to be nice to our users if we are going to proceed, IMHO.

jan-cerny commented 4 years ago

The temp files will be resolved by #239. The configuration file can be solved by a separate PR.