Page MenuHomePhabricator

whonix-setup-wizard, more generic state file mechanism for status files
Closed, ResolvedPublic

Description

We have

  • /home/user/.gateway/first_use_check.done
  • /var/lib/whonix/do_once/whonixsetup.done as whonix-repository-wizard done file
  • We also need one for locale_settings_finish?

I am prosing a more generic approach. Here is an example:

  • /var/lib/whonix-setup-wizard/status-files/disclaimer.skip
  • /var/lib/whonix-setup-wizard/status-files/disclaimer.done
  • /var/cache/whonix-setup-wizard/status-files/disclaimer.skip
  • /var/cache/whonix-setup-wizard/status-files/disclaimer.done

/var/lib/whonix-setup-wizard:

Users, custom builders and derivative distributions (Whonix Qubes can be considered a derivative of Whonix) can use that one. whonix-setup-wizard never touches folder for writing. Also not during apt-get purge. Only for reading.

Whonix Qubes does not need/want the disclaimer, so their qubes-whonix package could ship a /var/lib/whonix-setup-wizard/status-files/disclaimer.skip file.


/var/cache/whonix-setup-wizard/status-files:

Used by whonix-setup-wizard for status files. Once the user accepted the disclaimer, a file /var/lib/whonix-setup-wizard/status-files/disclaimer.done could be created. And on next run, we can skip the disclaimer wizard page. The /var/cache/whonix-setup-wizard/status-files folder would not be deleted on apt-get remove, but it would be removed on apt-get purge.


We could also stick to the current convention whonix/do_once, since it's a Whonix specific application.


Having this mechanism, we could have a python function, that abstracts checking these two folders for existing status files. So we can run that function and say "if function says, state file exists, skip it, otherwise continue".


The apt-get remove vs purge distinction can very easily be implemented by me in debian/ maintainer scripts.


What do you think?

Event Timeline

Patrick created this task.Feb 10 2015, 4:28 AM
Patrick raised the priority of this task from to Normal.
Patrick updated the task description. (Show Details)
Patrick added subscribers: Patrick, HulaHoop, WhonixQubes and 2 others.

Yes, it's certainly better to skip the disclaimer pages when the user re-run the wizard. That means that in Workstation, it could be shown only once, at first boot (it has only disclaimer and whonix repository, if disclaimer.done and whonixsetup.done, that's it, only whonix repository available. It's not a problem).

We still need whonix/do_once anyhow, in order not to run the wizard at each boot (in Workstation), but it looks like only two new files are sufficient for achieving this.

  • /var/lib/whonix-setup-wizard/status-files/disclaimer.skip for Whonix Qupes or other derivatives not wanting the disclaimer. If the file exists, never show the pages.
  • /var/cache/whonix-setup-wizard/status-files/disclaimer.done could work the same way as /var/lib/whonix/do_once/whonixsetup.done(do not show the pages if the file exists).

Having this mechanism, we could have a python function, that abstracts checking these two folders for existing status files. So we can run that function and say "if function says, state file exists, skip it, otherwise continue".

The only place where to implement the check seems to be the wizard itself (a few more if. At some stage, will have to comment all that in the code, for future re-reading).

done state files: we have first_use_check.done, disclaimer.done and whonixsetup.done. Since they are all used exclusively by whonix-setup-wizard, they could be grouped in a single directory instead of being scattered in three different places.

whonixsetup.done could become whonix_repository.done. That's its exact function in Gateway, and in Workstation too, if we put aside the disclaimer.

The change for the done files is completed in whonix-setup-wizard. Provisionally, will create /var/cache/whonix-setup-wizard/status-files/ and write the state files there, except may be for disclaimer.skip.

Did you git push yet?

Done now.

Was a problem with whonix-repository when going back from the finish page. Do not delete the repository pages any longer, so the back button goes through all the pages. Apart from fixing the issue, it's sensible, I think, and the code is clearer.

Yeah, maybe just one folder with ".skip" and ".done" files will be better. Not 100% Debian policy compliant, but whonix-setup-wizard won't get into Debian anyhow, so it does not matter. This simpler solution is better overall.

You have one /var/lib/ left at the moment. The rest uses /var/cache.

What makes this non-intuitive is, that ".skip" and ".done" files are not supported for every action. That's why I suggested a function that abstracts /var/cache/whonix-setup-wizard/status-files/$varname[.skip|.done].

Pushed two commits.

  • bug when running repository only.
  • issue with locale_settings wizard size.

So, we say that all the status files should be in /var/cache/whonix-setup-wizard/status-files/?

Done, plus some cleaning.

Awesome! I will test it out tonight.

Patrick, Can you create a branch/tag and sign it for whonix-setup-wizard / pythton-guimessages so I can include it in the Qubes Whonix 9.6 release that I hope to have completed today or tomorrow?

I am wondering, if instead of having.

if environment == 'gateway' and show_disclaimer:
elif environment == 'gateway' and not show_disclaimer:

If it would require less code/duplication to skip the disclaimer in the actual function? But I don't know, it might not be (easily) possible.

show_disclaimer = (not os.path.exists('/var/cache/whonix-setup-wizard/status-files/disclaimer_done') and
                   not os.path.exists('/var/cache/whonix-setup-wizard/status-files/disclaimer_skip'))

Why _, i.e. why _skip and _done instead of .[...]?

For consistency, I think it would be better to also have whonix_repository.skip and first_use_check.skip.

And I am wondering, how could we deal with locale_settings[.done|.skip]? Because then whonix-setup-wizard runs as user, not root. Means there would be no write access to /var/cache/whonix-setup-wizard/status-files/, unless we set it to writeable by anyone. That would be easily doable by using a Debian maintainer script, if that is acceptable. (The policy conform way would be to write into the user's home folder, but then we wouldn't have a consistent /var/cache/whonix-setup-wizard/status-files/ folder.)

Added postinst script that creates /var/cache/whonix-setup-wizard/status-files folder:
https://github.com/Whonix/whonix-setup-wizard/commit/e7ab058dcc40de3a2c77d64aafed6da8191771d9

In T155#1895, @nrgaway wrote:

Patrick, Can you create a branch/tag and sign it for whonix-setup-wizard / pythton-guimessages so I can include it in the Qubes Whonix 9.6 release that I hope to have completed today or tomorrow?

--> T160

If it would require less code/duplication to skip the disclaimer in the actual function? But I don't know, it might not be (easily) possible.

No, we have to leave with this one (tried reducing the code duplication, could not find a way).

Why _, i.e. why _skip and _done instead of .[...]?

My mistake. https://github.com/troubadoour/whonix-setup-wizard/commit/04a7a34fd87616af0e428334eabdffce6edd79c1

The policy conform way would be to write into the user's home folder, but then we wouldn't have a consistent /var/cache/whonix-setup-wizard/status-files/ folder.

I'm not familiar with Debian policy, but, why not write all the files in ~/.whonix-setup-wizard/. That would solve the issue with locale_settings[.done|.skip]? This part of the wizard is run as user.

Okay, merged.

The policy conform way would be to write into the user's home folder, but then we wouldn't have a consistent /var/cache/whonix-setup-wizard/status-files/ folder.

I'm not familiar with Debian policy, but, why not write all the files in ~/.whonix-setup-wizard/. That would solve the issue with locale_settings[.done|.skip]? This part of the wizard is run as user. (underline added by me)

There would be two issues. 1) Which ~? user or root? 2) The worse issue is, that as per Debian policy, packages must not write into ~/. If the qubes-whonix package would add its .skip files there, then they would also have to add a lintian override, because lintian would report a grave issue for installing files to ~/.

OK.

In T155#1896, @Patrick wrote:

And I am wondering, how could we deal with locale_settings[.done|.skip]? Because then whonix-setup-wizard runs as user, not root. Means there would be no write access to /var/cache/whonix-setup-wizard/status-files/, unless we set it to writeable by anyone. That would be easily doable by using a Debian maintainer script, if that is acceptable. (The policy conform way would be to write into the user's home folder, but then we wouldn't have a consistent /var/cache/whonix-setup-wizard/status-files/ folder.)

I don't know what is better, policy wise, but as whonix-setup-wizard is too specific to be ever upstreamed, perhaps we're free to put it in /var/cache/whonix-setup-wizard/status-files/, writeable by anyone.

It just occurred to me, that I think I heard, that Tails managed to upstream tails-installer to Debian or is in process to. So it may not be impossible. Anyhow. Yes. For now that's the simplest and fastest solution. Let's go for it. Done, made it writeable by everyone:
https://github.com/Whonix/whonix-setup-wizard/commit/2cba459e7a2bba9b54b326177cf5af71b727b95b

Ok. Pushed a cosmetic update (PEP8 compatibility, step 1).

instead of /var/lib/whonix/do_once/whonixsetup.done create /var/cache/whonix-setup-wizard/status-files/whonixsetup.done - https://phabricator.whonix.org/T155 :
https://github.com/Whonix/whonix-setup-wizard/commit/3203700c6ad08e08ca0a987601c675a552eed987

fix, create /var/cache/whonix-setup-wizard/status-files/whonixsetup.done also on Whonix-Gateway:
https://github.com/Whonix/whonix-setup-wizard/commit/563462322791d060bb49d8c5632c8e50bb357b7c

Also done in whonixcheck.

instead of /var/lib/whonix/do_once/whonixsetup.done check for /var/cache/whonix-setup-wizard/status-files/whonixsetup.done - https://phabricator.whonix.org/T155 :
https://github.com/Whonix/whonixcheck/commit/fb02875f069f282aafb00218760c1f800c61c8cb

Done in whonixsetup (cli).

instead of /var/lib/whonix/do_once/whonixsetup.done use /var/cache/whonix-setup-wizard/status-files/whonixsetup.done - https://phabricator.whonix.org/T155:
https://github.com/Whonix/whonixsetup/commit/847b62eb81eed4e98e5dca2599484f08aa13e2d0

Last one.

instead of /var/lib/whonix/do_once/whonixsetup.done use /var/cache/whonix-setup-wizard/status-files/whonixsetup.done - https://phabricator.whonix.org/T155:
https://github.com/Whonix/whonix-setup-wizard/commit/5b379ec2e2dd27fd93e163fb4f35132d55d9fe0a

implemented /var/cache/whonix-setup-wizard/status-files/whonix_repository.skip and /var/cache/whonix-setup-wizard/status-files/first_use_check.skip:
https://github.com/Whonix/whonix-setup-wizard/commit/fc7aae5689f99755228a252916d18e874ff44c6d

added support for /var/cache/whonix-setup-wizard/status-files/whonixsetup.skip:
https://github.com/Whonix/whonix-setup-wizard/commit/c10ec2c5e45fa765536aba9ca372ea7aa68107a6

Patrick changed the task status from Open to Review.Mar 10 2015, 1:03 PM

Anything missing here, @troubadour?

Patrick closed this task as Resolved.Mar 11 2015, 9:50 PM
Patrick claimed this task.