Add an optional pkexec binary to create the system-update symlink

This commit is contained in:
Richard Hughes 2012-06-01 23:01:49 +01:00
parent 6425868eeb
commit fb39c0fcfe
6 changed files with 84 additions and 0 deletions

View File

@ -483,6 +483,13 @@ else
fi
AM_CONDITIONAL(PK_BUILD_PM_UTILS, test $build_pm_utils = "yes")
dnl ---------------------------------------------------------------------------
dnl - Able to use systemd updates functionality
dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE(systemd-updates, AS_HELP_STRING([--enable-systemd-updates],[Build systemd updates functionality]),
build_systemd_updates=$enableval,build_systemd_updates=yes)
AM_CONDITIONAL(PK_BUILD_SYSTEMD_UPDATES, test $build_systemd_updates = "yes")
# backends
AC_ARG_ENABLE(alpm, AS_HELP_STRING([--enable-alpm],[use the ALPM backend]),enable_alpm=$enableval,enable_alpm=no)
AC_ARG_ENABLE(apt, AS_HELP_STRING([--enable-apt],[use the APT backend]),enable_apt=$enableval,enable_apt=no)
@ -770,6 +777,7 @@ contrib/cron/Makefile
contrib/debuginfo-install/Makefile
contrib/device-rebind/Makefile
contrib/pm-utils/Makefile
contrib/systemd-updates/Makefile
backends/Makefile
backends/alpm/Makefile
backends/apt/Makefile
@ -841,6 +849,7 @@ echo "
Cron scripts: ${build_cron}
debuginfo-install: ${build_debuginfo_install}
device-rebind: ${build_device_rebind}
systemd-updates: ${build_systemd_updates}
pm-utils scripts: ${build_pm_utils}
QT library: ${build_qt}

View File

@ -36,6 +36,10 @@ if PK_BUILD_DEVICE_REBIND
SUBDIRS += device-rebind
endif
if PK_BUILD_SYSTEMD_UPDATES
SUBDIRS += systemd-updates
endif
bashcompletiondir = ${SYSCONFDIR}/bash_completion.d
dist_bashcompletion_DATA = pk-completion.bash

View File

@ -328,6 +328,7 @@ update-mime-database %{_datadir}/mime &> /dev/null || :
%{_datadir}/mime/packages/packagekit-*.xml
%{_datadir}/PackageKit/pk-upgrade-distro.sh
%{_libexecdir}/packagekitd
%{_libexecdir}/pk-trigger-offline-update
%{_bindir}/pkmon
%{_bindir}/pkcon
%{_bindir}/pkgenpack

View File

@ -0,0 +1,6 @@
libexec_PROGRAMS = pk-trigger-offline-update
pk_trigger_offline_update_SOURCES = \
pk-trigger-offline-update.c
pk_trigger_offline_update_CFLAGS = \
$(WARNINGFLAGS_C)

View File

@ -0,0 +1,48 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2012 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
int
main (int argc, char *argv[])
{
int rc;
/* ensure root user */
if (getuid () != 0 || geteuid () != 0) {
fprintf (stderr, "This program can only be used using pkexec\n");
return EXIT_FAILURE;
}
/* create symlink for the systemd-system-update-generator */
rc = symlink ("/var/cache", "/system-update");
if (rc < 0) {
fprintf (stderr, "Failed to create symlink: %s\n",
strerror (errno));
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

View File

@ -267,5 +267,21 @@
</defaults>
</action>
<action id="org.freedesktop.packagekit.trigger-offline-update">
<!-- SECURITY:
- Normal users are able to ask updates to be installed at
early boot time without a password.
-->
<_description>Trigger offline updates</_description>
<_message>Authentication is required to trigger offline updates</_message>
<icon_name>package-x-generic</icon_name>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/libexec/pk-trigger-offline-update</annotate>
</action>
</policyconfig>