/* === This file is part of Calamares - === * * SPDX-FileCopyrightText: 2020 Adriaan de Groot * 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 . */ #ifndef USERS_CONFIG_H #define USERS_CONFIG_H #include #include class Config : public QObject { Q_OBJECT Q_PROPERTY( QString userShell READ userShell WRITE setUserShell NOTIFY userShellChanged ) Q_PROPERTY( QString autologinGroup READ autologinGroup WRITE setAutologinGroup NOTIFY autologinGroupChanged ) Q_PROPERTY( QString sudoersGroup READ sudoersGroup WRITE setSudoersGroup NOTIFY sudoersGroupChanged ) Q_PROPERTY( QString userName READ userName WRITE setUserName NOTIFY userNameChanged ) Q_PROPERTY( QString loginName READ loginName WRITE setLoginName NOTIFY loginNameChanged ) Q_PROPERTY( QString hostName READ hostName WRITE setHostName NOTIFY hostNameChanged ) public: Config( QObject* parent = nullptr ); ~Config(); void setConfigurationMap( const QVariantMap& ); /** @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; } /// 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; } /// The full (GECOS) name of the user QString userName() const { return m_fullName; } /// The login name of the user QString loginName() const { return m_loginName; } /// The host name (name for the system) QString hostName() const { return m_hostName; } 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 ); /// Sets the autologin group; empty is ignored void setAutologinGroup( const QString& group ); /// Sets the sudoer group; empty is ignored void setSudoersGroup( const QString& group ); /// Sets the full name, may guess a loginName void setUserName( const QString& name ); /// Sets the login name (flags it as "custom") void setLoginName( const QString& login ); /// Sets the host name (flags it as "custom") void setHostName( const QString& host ); signals: void userShellChanged( const QString& ); void autologinGroupChanged( const QString& ); void sudoersGroupChanged( const QString& ); void userNameChanged( const QString& ); void loginNameChanged( const QString& ); void hostNameChanged( const QString& ); private: QString m_userShell; QString m_autologinGroup; QString m_sudoersGroup; QString m_fullName; QString m_loginName; QString m_hostName; bool m_customLoginName = false; bool m_customHostName = false; }; #endif