[gnome-continuous] testbase: create user via accountservice and properly set desired session
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous] testbase: create user via accountservice and properly set desired session
- Date: Fri, 2 May 2014 14:41:16 +0000 (UTC)
commit 588cb15a05d3cba101a13d545832933068fb9154
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Fri May 2 16:31:40 2014 +0200
testbase: create user via accountservice and properly set desired session
src/js/libqa.js | 31 +++++++++++++------------------
src/js/tasks/testbase.js | 5 +----
2 files changed, 14 insertions(+), 22 deletions(-)
---
diff --git a/src/js/libqa.js b/src/js/libqa.js
index 59c0d24..efe0e49 100644
--- a/src/js/libqa.js
+++ b/src/js/libqa.js
@@ -218,15 +218,22 @@ RateLimitInterval=0\n', null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, ca
}
function injectTestUserCreation(currentDir, currentEtcDir, username, params, cancellable) {
- params = Params.parse(params, { password: null });
- let execLine;
+ params = Params.parse(params, { password: null, session: null });
+ let execLine, passwordCommand, setSessionCommand;
+ let commandTemplate = '/usr/bin/dbus-send --system --type=method_call --print-reply' +
+ ' --dest=org.freedesktop.Accounts /org/freedesktop/Accounts%s org.freedesktop.Accounts.%s %s'
+
+ let addUserCommand = Format.vprintf(commandTemplate, ['', 'CreateUser', 'string:' + username + ' string:
int32:0'])
if (params.password === null) {
- execLine = Format.vprintf('/bin/sh -c "/usr/sbin/useradd %s; passwd -d %s"',
- [username, username]);
+ passwordCommand = Format.vprintf(commandTemplate, ['/User1000', 'User.SetPassword', 'string:
string:'])
} else {
- execLine = Format.vprintf('/bin/sh -c "/usr/sbin/useradd %s; echo %s | passwd --stdin %s',
- [username, params.password, username]);
+ // AccountService requires passing a crypt, so using passwd would be easier
+ passwordCommand = Format.vprintf("echo %s | passwd --stdin %s", [params.password, username]);
+ }
+ if (params.session != null) {
+ setSessionCommand = Format.vprintf(commandTemplate, ['/User1000', 'User.SetXSession', 'string:' +
params.session])
}
+ execLine = Format.vprintf('/bin/sh -c "%s"; /bin/sh -c "%s"; /bin/sh -c "%s"', [addUserCommand,
passwordCommand, setSessionCommand])
let addUserService = '[Unit]\n\
Description=Add user %s\n\
Before=multi-user.target\n\
@@ -249,18 +256,6 @@ function enableAutologin(currentDir, currentEtcDir, username, cancellable) {
gdmCustomPath.replace_contents(keyfile.to_data()[0], null, false,
Gio.FileCreateFlags.REPLACE_DESTINATION, cancellable);
}
-function setAutologinSession(currentDir, username, session, cancellable) {
- let usersDir = currentDir.resolve_relative_path('var/lib/AccountsService/users');
- GSystem.file_ensure_directory(usersDir, true, cancellable);
- let userFile = usersDir.resolve_relative_path(username);
- let userFileContents = '[User]\n\
-Language=\n\
-XSession=%s\n\
-SystemAccount=false\n';
- userFileContents = Format.vprintf(userFileContents, [session]);
- userFile.replace_contents(userFileContents, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION,
cancellable);
-}
-
function _findFirstFileMatching(dir, prefix, cancellable) {
let d = dir.enumerate_children('standard::*', Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, cancellable);
let finfo;
diff --git a/src/js/tasks/testbase.js b/src/js/tasks/testbase.js
index 9a2e503..3f90992 100644
--- a/src/js/tasks/testbase.js
+++ b/src/js/tasks/testbase.js
@@ -450,12 +450,9 @@ const TestOneDisk = new Lang.Class({
LibQA.injectExportJournal(currentDir, currentEtcDir, cancellable);
const username = 'testuser';
- LibQA.injectTestUserCreation(currentDir, currentEtcDir, username, {}, cancellable);
+ LibQA.injectTestUserCreation(currentDir, currentEtcDir, username, {session: this._gdmSession},
cancellable);
LibQA.enableAutologin(currentDir, currentEtcDir, username, cancellable);
- if (this._gdmSession)
- LibQA.setAutologinSession(currentDir, username, this._gdmSession, cancellable);
-
this._parentTask._prepareDisk(mntdir, this._diskArch, cancellable);
} finally {
gfmnt.umount(cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]