2020-07-25 12:47:01 +02:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
|
|
*
|
|
|
|
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
* License-Filename: LICENSE
|
|
|
|
*
|
|
|
|
* Calamares 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef USERS_CONFIG_H
|
|
|
|
#define USERS_CONFIG_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QVariantMap>
|
|
|
|
|
|
|
|
class Config : public QObject
|
|
|
|
{
|
2020-07-25 15:39:19 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( QString userShell READ userShell WRITE setUserShell NOTIFY userShellChanged )
|
|
|
|
|
2020-07-25 16:39:13 +02:00
|
|
|
Q_PROPERTY( QString autologinGroup READ autologinGroup WRITE setAutologinGroup NOTIFY autologinGroupChanged )
|
|
|
|
Q_PROPERTY( QString sudoersGroup READ sudoersGroup WRITE setSudoersGroup NOTIFY sudoersGroupChanged )
|
|
|
|
|
2020-07-28 11:41:52 +02:00
|
|
|
Q_PROPERTY( bool doAutoLogin READ doAutoLogin WRITE setAutoLogin NOTIFY autoLoginChanged )
|
|
|
|
|
2020-07-27 17:52:46 +02:00
|
|
|
Q_PROPERTY( QString fullName READ fullName WRITE setFullName NOTIFY fullNameChanged )
|
2020-07-25 16:54:15 +02:00
|
|
|
Q_PROPERTY( QString loginName READ loginName WRITE setLoginName NOTIFY loginNameChanged )
|
2020-07-28 10:21:23 +02:00
|
|
|
Q_PROPERTY( QString loginNameStatus READ loginNameStatus NOTIFY loginNameStatusChanged )
|
2020-07-25 16:54:15 +02:00
|
|
|
|
2020-07-27 15:54:52 +02:00
|
|
|
Q_PROPERTY( QString hostName READ hostName WRITE setHostName NOTIFY hostNameChanged )
|
2020-07-28 10:45:38 +02:00
|
|
|
Q_PROPERTY( QString hostNameStatus READ hostNameStatus NOTIFY hostNameStatusChanged )
|
2020-07-27 15:54:52 +02:00
|
|
|
|
2020-07-25 12:47:01 +02:00
|
|
|
public:
|
|
|
|
Config( QObject* parent = nullptr );
|
|
|
|
~Config();
|
|
|
|
|
|
|
|
void setConfigurationMap( const QVariantMap& );
|
2020-07-25 15:39:19 +02:00
|
|
|
|
|
|
|
/** @brief Full path to the user's shell executable
|
|
|
|
*
|
|
|
|
* Typically this will be /bin/bash, but it can be set from
|
|
|
|
* the config file with the *userShell* setting.
|
|
|
|
*/
|
|
|
|
QString userShell() const { return m_userShell; }
|
|
|
|
|
2020-07-25 16:39:13 +02:00
|
|
|
/// The group of which auto-login users must be a member
|
|
|
|
QString autologinGroup() const { return m_autologinGroup; }
|
|
|
|
/// The group of which users who can "sudo" must be a member
|
|
|
|
QString sudoersGroup() const { return m_sudoersGroup; }
|
|
|
|
|
2020-07-25 16:54:15 +02:00
|
|
|
/// The full (GECOS) name of the user
|
2020-07-27 17:52:46 +02:00
|
|
|
QString fullName() const { return m_fullName; }
|
2020-07-25 16:54:15 +02:00
|
|
|
/// The login name of the user
|
|
|
|
QString loginName() const { return m_loginName; }
|
2020-07-28 10:21:23 +02:00
|
|
|
/// Status message about login -- empty for "ok"
|
|
|
|
QString loginNameStatus() const;
|
2020-07-25 16:54:15 +02:00
|
|
|
|
2020-07-27 15:54:52 +02:00
|
|
|
/// The host name (name for the system)
|
|
|
|
QString hostName() const { return m_hostName; }
|
2020-07-28 10:45:38 +02:00
|
|
|
/// Status message about hostname -- empty for "ok"
|
|
|
|
QString hostNameStatus() const;
|
2020-07-27 15:54:52 +02:00
|
|
|
|
2020-07-28 11:41:52 +02:00
|
|
|
/// Should the user be automatically logged-in?
|
|
|
|
bool doAutoLogin() const { return m_doAutoLogin; }
|
2020-07-28 11:59:53 +02:00
|
|
|
/// Should the root password be written (if false, no password is set and the root account is disabled for login)
|
|
|
|
bool writeRootPassword() const { return m_writeRootPassword; }
|
2020-07-28 11:41:52 +02:00
|
|
|
|
2020-07-28 10:21:23 +02:00
|
|
|
static const QStringList& forbiddenLoginNames();
|
2020-07-28 10:45:38 +02:00
|
|
|
static const QStringList& forbiddenHostNames();
|
2020-07-28 10:21:23 +02:00
|
|
|
|
2020-07-25 15:39:19 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
/** @brief Sets the user's shell if possible
|
|
|
|
*
|
|
|
|
* If the path is empty, that's ok: no shell will be explicitly set,
|
|
|
|
* so the user will get whatever shell is set to default in the target.
|
|
|
|
*
|
|
|
|
* The given non-empty @p path must be an absolute path (for use inside
|
|
|
|
* the target system!); if it is not, the shell is not changed.
|
|
|
|
*/
|
|
|
|
void setUserShell( const QString& path );
|
|
|
|
|
2020-07-25 16:39:13 +02:00
|
|
|
/// Sets the autologin group; empty is ignored
|
|
|
|
void setAutologinGroup( const QString& group );
|
|
|
|
/// Sets the sudoer group; empty is ignored
|
|
|
|
void setSudoersGroup( const QString& group );
|
|
|
|
|
2020-07-25 16:54:15 +02:00
|
|
|
/// Sets the full name, may guess a loginName
|
2020-07-27 17:52:46 +02:00
|
|
|
void setFullName( const QString& name );
|
2020-07-27 15:34:59 +02:00
|
|
|
/// Sets the login name (flags it as "custom")
|
2020-07-25 16:54:15 +02:00
|
|
|
void setLoginName( const QString& login );
|
|
|
|
|
2020-07-27 15:54:52 +02:00
|
|
|
/// Sets the host name (flags it as "custom")
|
|
|
|
void setHostName( const QString& host );
|
|
|
|
|
2020-07-28 11:41:52 +02:00
|
|
|
/// Sets the autologin flag
|
|
|
|
void setAutoLogin( bool b );
|
|
|
|
|
2020-07-25 15:39:19 +02:00
|
|
|
signals:
|
|
|
|
void userShellChanged( const QString& );
|
2020-07-25 16:39:13 +02:00
|
|
|
void autologinGroupChanged( const QString& );
|
|
|
|
void sudoersGroupChanged( const QString& );
|
2020-07-27 17:52:46 +02:00
|
|
|
void fullNameChanged( const QString& );
|
2020-07-25 16:54:15 +02:00
|
|
|
void loginNameChanged( const QString& );
|
2020-07-28 10:21:23 +02:00
|
|
|
void loginNameStatusChanged( const QString& );
|
2020-07-27 15:54:52 +02:00
|
|
|
void hostNameChanged( const QString& );
|
2020-07-28 10:45:38 +02:00
|
|
|
void hostNameStatusChanged( const QString& );
|
2020-07-28 11:41:52 +02:00
|
|
|
void autoLoginChanged( bool );
|
2020-07-25 15:39:19 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_userShell;
|
2020-07-25 16:39:13 +02:00
|
|
|
QString m_autologinGroup;
|
|
|
|
QString m_sudoersGroup;
|
2020-07-25 16:54:15 +02:00
|
|
|
QString m_fullName;
|
|
|
|
QString m_loginName;
|
2020-07-27 15:54:52 +02:00
|
|
|
QString m_hostName;
|
2020-07-28 11:41:52 +02:00
|
|
|
bool m_doAutoLogin = false;
|
2020-07-28 11:59:53 +02:00
|
|
|
bool m_writeRootPassword = true;
|
2020-07-28 11:41:52 +02:00
|
|
|
|
2020-07-27 15:34:59 +02:00
|
|
|
bool m_customLoginName = false;
|
2020-07-27 15:54:52 +02:00
|
|
|
bool m_customHostName = false;
|
2020-07-25 12:47:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|