accounts-service: Rename allow-app-installation to be system-specific

This is in preparation for adding a second boolean for the flatpak user
repository. Make the existing allow-app-installation boolean control
permissions for the flatpak system repository.

Having one boolean for each repository means we can allow users to
install to their user repository by default (subject to OARS ratings),
but not be allowed to install to the system repository.

While changing the name and semantics of the boolean, flip its default
value from True to False. Rather than letting any non-admin user install
new apps by default (subject to OARS restrictions), re-limit it to admin
users and users whose allow-system-installation key has been explicitly
set to True by the admin.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://phabricator.endlessm.com/T24457
This commit is contained in:
Philip Withnall 2018-11-28 16:39:39 +00:00
parent f2e7cbfd03
commit 3ec77740c7
5 changed files with 66 additions and 61 deletions

View file

@ -138,10 +138,10 @@ def command_get(user, quiet=False, interactive=True):
if not sections:
print(' (No OARS values)')
if app_filter.is_app_installation_allowed():
print('App installation is allowed')
if app_filter.is_system_installation_allowed():
print('App installation is allowed to system repository')
else:
print('App installation is disallowed')
print('App installation is disallowed to system repository')
def command_check(user, path, quiet=False, interactive=True):
@ -186,12 +186,12 @@ def command_oars_section(user, section, quiet=False, interactive=True):
section, user_id, __oars_value_to_string(value)))
def command_set(user, allow_app_installation=True, app_filter_args=None,
def command_set(user, allow_system_installation=False, app_filter_args=None,
quiet=False, interactive=True):
"""Set the app filter for the given user."""
user_id = __lookup_user_id_or_error(user)
builder = EosParentalControls.AppFilterBuilder.new()
builder.set_allow_app_installation(allow_app_installation)
builder.set_allow_system_installation(allow_system_installation)
for arg in app_filter_args:
if '=' in arg:
@ -277,17 +277,20 @@ def main():
parser_set.add_argument('user', default='', nargs='?',
help='user ID or username to get the app filter '
'for (default: current user)')
parser_set.add_argument('--allow-app-installation',
dest='allow_app_installation', action='store_true',
help='allow app installation in general')
parser_set.add_argument('--disallow-app-installation',
dest='allow_app_installation',
parser_set.add_argument('--allow-system-installation',
dest='allow_system_installation',
action='store_true',
help='allow installation to the system flatpak '
'repo in general')
parser_set.add_argument('--disallow-system-installation',
dest='allow_system_installation',
action='store_false',
help='unconditionally disallow app installation')
help='unconditionally disallow installation to '
'the system flatpak repo')
parser_set.add_argument('app_filter_args', nargs='*',
help='paths to blacklist and OARS section=value '
'pairs to store')
parser_set.set_defaults(allow_app_installation=True)
parser_set.set_defaults(allow_system_installation=False)
# Parse the command line arguments and run the subcommand.
args = parser.parse_args()