feature(version): Init commit for v2.5 version

- 第一次提交v2.5版本

Signed-off-by: meizhigang <meizhigang@kylinsec.com.cn>
This commit is contained in:
meizhigang 2023-03-24 17:58:18 +08:00
parent 1ad8d73dad
commit 5e480692dd
6 changed files with 8 additions and 1908 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,162 +0,0 @@
From 929f76de69e1e14f5f52925da9f05c577acaea7b Mon Sep 17 00:00:00 2001
From: tangjie02 <tangjie02@kylinsec.com.cn>
Date: Fri, 28 Oct 2022 15:34:01 +0800
Subject: [PATCH] feature(timedate): Delete timedate_i.h file.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 删除timedate_i.h文件因为文件命名格式错误。
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
---
include/timedate-i.h | 32 +++++++++++++++--
include/timedate_i.h | 51 ---------------------------
plugins/timedate/timedate-format.h | 3 +-
plugins/timedate/timedate-manager.cpp | 8 ++---
4 files changed, 34 insertions(+), 60 deletions(-)
delete mode 100644 include/timedate_i.h
diff --git a/include/timedate-i.h b/include/timedate-i.h
index d80caf9..6091b6c 100644
--- a/include/timedate-i.h
+++ b/include/timedate-i.h
@@ -14,5 +14,33 @@
#pragma once
-#define TIMEDATE_NEW_INTERFACE
-#include <kiran-system-daemon/timedate_i.h>
\ No newline at end of file
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define TIMEDATE_DBUS_NAME "com.kylinsec.Kiran.SystemDaemon.TimeDate"
+#define TIMEDATE_OBJECT_PATH "/com/kylinsec/Kiran/SystemDaemon/TimeDate"
+#define TIMEDATE_DBUS_INTERFACE_NAME "com.kylinsec.Kiran.SystemDaemon.TimeDate"
+
+ enum TimedateDateFormatType
+ {
+ // 时间日期的长格式
+ TIMEDATE_FORMAT_TYPE_LONG = 0,
+ // 时间日期的短格式
+ TIMEDATE_FORMAT_TYPE_SHORT,
+ TIMEDATE_FORMAT_TYPE_LAST,
+ };
+
+ enum TimedateHourFormat
+ {
+ // 12小时制
+ TIMEDATE_HOUSR_FORMAT_12_HOURS = 0,
+ // 24小时制
+ TIMEDATE_HOUSR_FORMAT_24_HOURS,
+ TIMEDATE_HOUSR_FORMAT_LAST
+ };
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
diff --git a/include/timedate_i.h b/include/timedate_i.h
deleted file mode 100644
index 4607553..0000000
--- a/include/timedate_i.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) 2020 ~ 2021 KylinSec Co., Ltd.
- * kiran-cc-daemon is licensed under Mulan PSL v2.
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
- * You may obtain a copy of Mulan PSL v2 at:
- * http://license.coscl.org.cn/MulanPSL2
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- * See the Mulan PSL v2 for more details.
- *
- * Author: tangjie02 <tangjie02@kylinos.com.cn>
- */
-
-
-#pragma once
-
-#ifndef TIMEDATE_NEW_INTERFACE
-#warning This file will be deprecated. please use timedate-i.h file
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define TIMEDATE_DBUS_NAME "com.kylinsec.Kiran.SystemDaemon.TimeDate"
-#define TIMEDATE_OBJECT_PATH "/com/kylinsec/Kiran/SystemDaemon/TimeDate"
-#define TIMEDATE_DBUS_INTERFACE_NAME "com.kylinsec.Kiran.SystemDaemon.TimeDate"
-
- enum TimedateDateFormatType
- {
- // 时间日期的长格式
- TIMEDATE_FORMAT_TYPE_LONG = 0,
- // 时间日期的短格式
- TIMEDATE_FORMAT_TYPE_SHORT,
- TIMEDATE_FORMAT_TYPE_LAST,
- };
-
- enum TimedateHourFormat
- {
- // 12小时制
- TIMEDATE_HOUSR_FORMAT_12_HOURS = 0,
- // 24小时制
- TIMEDATE_HOUSR_FORMAT_24_HOURS,
- TIMEDATE_HOUSR_FORMAT_LAST
- };
-
-#ifdef __cplusplus
-}
-#endif
\ No newline at end of file
diff --git a/plugins/timedate/timedate-format.h b/plugins/timedate/timedate-format.h
index 764b7d8..f938bba 100644
--- a/plugins/timedate/timedate-format.h
+++ b/plugins/timedate/timedate-format.h
@@ -16,8 +16,7 @@
#include "lib/base/base.h"
-#define TIMEDATE_NEW_INTERFACE
-#include "timedate_i.h"
+#include "timedate-i.h"
namespace Kiran
{
diff --git a/plugins/timedate/timedate-manager.cpp b/plugins/timedate/timedate-manager.cpp
index 6978874..92a4147 100644
--- a/plugins/timedate/timedate-manager.cpp
+++ b/plugins/timedate/timedate-manager.cpp
@@ -33,8 +33,7 @@
#include "plugins/timedate/timedate-def.h"
#include "plugins/timedate/timedate-util.h"
-#define TIMEDATE_NEW_INTERFACE
-#include "timedate_i.h"
+#include "timedate-i.h"
#ifdef HAVE_SELINUX
#include <selinux/selinux.h>
@@ -899,9 +898,8 @@ bool TimedateManager::check_timezone_name(const std::string &name)
name.length() > MAX_TIMEZONE_LENGTH)
return false;
- auto iter = std::find_if(name.begin(), name.end(), [](char c) -> bool {
- return !g_ascii_isalnum(c) && !strchr("+-_/", c);
- });
+ auto iter = std::find_if(name.begin(), name.end(), [](char c) -> bool
+ { return !g_ascii_isalnum(c) && !strchr("+-_/", c); });
if (iter != name.end())
{
--
2.33.0

View File

@ -1,110 +0,0 @@
From 90310b4ca83d1b91a91e98f505d1b2c918f78297 Mon Sep 17 00:00:00 2001
From: tangjie02 <tangjie02@kylinsec.com.cn>
Date: Mon, 14 Nov 2022 19:47:05 +0800
Subject: [PATCH] fix(passwd): Fix password policy inconsistencies.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复密码策略不一致问题
Closes #I60Q7P
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
---
plugins/accounts/passwd-wrapper.cpp | 34 +++++++++++++++++++++--------
plugins/accounts/user.cpp | 2 ++
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/plugins/accounts/passwd-wrapper.cpp b/plugins/accounts/passwd-wrapper.cpp
index 860fa7a..8ce454d 100644
--- a/plugins/accounts/passwd-wrapper.cpp
+++ b/plugins/accounts/passwd-wrapper.cpp
@@ -141,8 +141,9 @@ void PasswdWrapper::on_child_setup(uint32_t caller_uid)
// 如果是设置当前用户密码,则需要进行降权
if (caller_uid == user->uid_get())
{
- if (setuid(user->uid_get()) != 0 ||
- setgid(user->gid_get()) != 0)
+ // 必须先设置gid然后再设置uid否则在设置uid后已经不是特权用户无法设置gid
+ if (setgid(user->gid_get()) != 0 ||
+ setuid(user->uid_get()) != 0)
{
exit(1);
}
@@ -196,8 +197,8 @@ bool PasswdWrapper::on_passwd_output(Glib::IOCondition io_condition, Glib::RefPt
auto retval = this->process_passwd_output_line(handled_passwd_tips);
- // 处理出错,直接退出
- if (!this->additional_error_message_.empty())
+ // 处理出错且后面不再有数据则退出
+ if (!this->additional_error_message_.empty() && this->unhandled_passwd_tips_.empty())
{
this->end_passwd(false);
break;
@@ -277,7 +278,8 @@ bool PasswdWrapper::process_passwd_output_line(const std::string &line)
this->in_io_channel_->write(this->new_password_ + "\n");
retval = true;
}
- // 如果是整行信息,说明出现了错误
+ /* 如果是整行信息,说明是错误或者告警信息。因为这里没法区分是错误或者告警信息,所以只能继续往下处理到数据结束,
+ 如果最后一条是提示信息,说明当前属于告警信息,否则是错误信息。*/
else if (line.find_first_of('\n') != std::string::npos)
{
this->state_ = PASSWD_STATE_ERROR;
@@ -304,6 +306,17 @@ bool PasswdWrapper::process_passwd_output_line(const std::string &line)
retval = true;
}
break;
+ case PASSWD_STATE_ERROR:
+ {
+ // 这里说明上一条信息是告警消息而非错误消息,因此清空错误消息并继续往下走
+ if (StrUtils::endswith(lowercase_passwd_tips, "retype new password: "))
+ {
+ this->state_ = PASSWD_STATE_RETYPE;
+ this->in_io_channel_->write(this->new_password_ + "\n");
+ this->additional_error_message_.clear();
+ retval = true;
+ }
+ }
default:
retval = true;
break;
@@ -314,13 +327,16 @@ bool PasswdWrapper::process_passwd_output_line(const std::string &line)
void PasswdWrapper::on_child_watch(GPid pid, int child_status)
{
- KLOG_DEBUG("Process passwd(%d) exit.", (int32_t)pid);
+ KLOG_DEBUG("Process passwd(%d) exit, exit status: %d.", (int32_t)pid, child_status);
- if (WIFEXITED(child_status))
+ g_autoptr(GError) g_error = NULL;
+ auto result = g_spawn_check_exit_status(child_status, &g_error);
+ if (!result)
{
- if (WEXITSTATUS(child_status) >= 255)
+ KLOG_WARNING("%s.", g_error->message);
+ if (this->error_message_.empty())
{
- KLOG_WARNING("Child exited unexpectedly");
+ this->error_message_ = CC_ERROR2STR(CCErrorCode::ERROR_FAILED);
}
}
diff --git a/plugins/accounts/user.cpp b/plugins/accounts/user.cpp
index 7835bb4..c8abf37 100644
--- a/plugins/accounts/user.cpp
+++ b/plugins/accounts/user.cpp
@@ -749,6 +749,8 @@ void User::change_password_by_passwd_authorized_cb(MethodInvocation invocation,
auto current_password = CryptoHelper::rsa_decrypt(AccountsManager::get_instance()->get_rsa_private_key(), encrypted_current_password);
auto new_password = CryptoHelper::rsa_decrypt(AccountsManager::get_instance()->get_rsa_private_key(), encrypted_new_password);
+ // KLOG_DEBUG("The currentPassword: %s, newPassword: %s.", current_password.c_str(), new_password.c_str());
+
if (this->passwd_wrapper_ && this->passwd_wrapper_->get_state() != PasswdState::PASSWD_STATE_NONE)
{
DBUS_ERROR_REPLY_AND_RET(CCErrorCode::ERROR_ACCOUNTS_USER_MODIFYING_PASSWORD);
--
2.33.0

Binary file not shown.

Binary file not shown.

View File

@ -1,15 +1,11 @@
Name: kiran-cc-daemon
Version: 2.4.0
Release: 4
Version: 2.5.0
Release: 1
Summary: DBus daemon for Kiran Desktop
License: MulanPSL-2.0
Source0: %{name}-%{version}.tar.gz
Patch0001: 0001-feature-timedate-Delete-timedate_i.h-file.patch
Patch0002: 0001-fix-passwd-Fix-password-policy-inconsistencies.patch
Patch0003: 0001-feature-backlight-Support-brightness-modification-by.patch
BuildRequires: cmake >= 3.2
BuildRequires: pkgconfig(glibmm-2.4)
@ -57,6 +53,7 @@ Requires: libgtop2
Requires: libgudev
Requires: lshw
Requires: passwd
Requires: iso-codes
%if 0%{?openEuler}
@ -140,6 +137,9 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
%{_datadir}/polkit-1/actions/com.kylinsec.Kiran.SessionDaemon*.policy
%dir %{_datadir}/kiran-cc-daemon/keybindings
%{_datadir}/kiran-cc-daemon/keybindings/*.xml
%{_datadir}/kiran-cc-daemon/kiran-session-daemon.gresource
%dir %{_datadir}/kiran-cc-daemon/images
%{_datadir}/kiran-cc-daemon/images/*.png
%files common
%{_includedir}/kiran-cc-daemon/error-i.h
@ -154,15 +154,6 @@ glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/nulls || :
%{_libdir}/pkgconfig/kiran-cc-daemon.pc
%changelog
* Wed Dec 07 2022 tangjie02 <tangjie02@kylinsec.com.cn> - 2.4.0-4
- KYOS-F: Support brightness modification by changing gamma value.
* Tue Nov 15 2022 tangjie02 <tangjie02@kylinsec.com.cn> - 2.4.0-3
- KYOS-B: Fix password policy inconsistencies.(I60Q7P)
* Fri Oct 28 2022 tangjie02 <tangjie02@kylinsec.com.cn> - 2.4.0-2
- KYOS-F: Delete timedate_i.h file.
* Tue Oct 25 2022 tangjie02 <tangjie02@kylinsec.com.cn> - 2.4.0-1
- KYOS-F: init commit for v2.4 version.
* Fri Mar 24 2023 meizhigang <meizhigang@kylinsec.com.cn> - 2.5.0-1
- KYOS-F: init commit for v2.5 version.