fix bug 181529 184238 180502 184351;update changelog

This commit is contained in:
shaozhimin 2023-07-28 11:10:58 +08:00
parent df91997b71
commit 6a80ee5734
5 changed files with 93 additions and 151 deletions

8
debian/changelog vendored
View File

@ -1,3 +1,11 @@
libkysdk-system (2.2.3.5-0k0.7) yangtze; urgency=medium
*Bug号181529 184238 180502 184351
*需求号:
*其他修改:
-- szm-min <shaozhimin@kylinos.cn> Fri, 28 Jul 2023 11:05:21 +0800
libkysdk-system (2.2.3.5-0k0.6) yangtze; urgency=medium
*Bug号

View File

@ -735,6 +735,7 @@ char* kdk_get_hard_model(const char *hardname)
strstripspace(hard_model);
}
else{
free(hard_model);
return NULL;
}
return hard_model;
@ -835,6 +836,11 @@ char* kdk_get_hard_serial(const char *hardname)
}
}
}
if(strlen(hard_serial) == 0)
{
free(hard_serial);
return NULL;
}
return hard_serial;
}
@ -849,6 +855,7 @@ char* kdk_get_hard_vendor(const char *hardname)
{
return NULL;
}
memset(hard_vendor, 0, 128);
char name[64] = "\0";
struct HWInfo *result = NULL;
@ -884,6 +891,11 @@ char* kdk_get_hard_vendor(const char *hardname)
{
strcpy(hard_vendor, "Seagate");
}
if(strlen(hard_vendor) == 0)
{
free(hard_vendor);
return NULL;
}
return hard_vendor;
}

View File

@ -775,7 +775,7 @@ char **kdk_net_get_up_port()
}
fclose(fp);
fp = fopen("/proc/net/tcp", "r");
fp = fopen("/proc/net/tcp6", "r");
if (!fp)
return NULL;
while (fgets(line, 1024, fp))
@ -898,10 +898,10 @@ char *kdk_net_get_hosts_domain()
char **kdk_net_get_resolv_conf()
{
char nserver[16] = "\0";
char addr[16] = "\0";
char nserver[64] = "\0";
char addr[64] = "\0";
char **result = NULL;
result = (char **)realloc(result, sizeof(char *) * 128); // 以NULL结尾
result = (char **)realloc(result, sizeof(char *) * 256); // 以NULL结尾
if (!result)
{
return NULL;
@ -919,7 +919,7 @@ char **kdk_net_get_resolv_conf()
{
if (strstr(line, "nameserver"))
{
result[index] = (char *)malloc(sizeof(char) * 128);
result[index] = (char *)malloc(sizeof(char) * 256);
if (!result[index])
{
fclose(fp);

View File

@ -14,6 +14,8 @@
#include <sys/inotify.h>
#include <libintl.h>
#include <locale.h>
#include <sys/stat.h>
#include <sys/types.h>
char path[100]; //用户修改后配置文件路径
#define PATH_MAX 100
@ -517,6 +519,7 @@ void *actionDateChanged(void *ptr)
{
DBusConnection *conn = NULL;
conn = ptr;
char strpath[128] = "\0";
int fd = inotify_init();
@ -524,6 +527,34 @@ void *actionDateChanged(void *ptr)
homeDir = getenv("HOME");
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
sprintf(strpath, "%s/.config/kydate/", homeDir);
if (access(strpath, F_OK) != 0)
{
int status = mkdir(strpath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (status != 0) {
return NULL;
}
FILE *fp = fopen(path, "w");
if(!fp)
{
close(fd);
return NULL;
}
fclose(fp);
}
else{
if(access(path, F_OK) != 0)
{
FILE *fp = fopen(path, "w");
if(!fp)
{
close(fd);
return NULL;
}
fclose(fp);
}
}
int fdate = inotify_add_watch(fd, path, IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MODIFY | IN_MOVE_SELF );
if (fdate < 0)

View File

@ -342,16 +342,6 @@ int kdk_system_set_dateformat(char *date)
}
}
// if(access(path,F_OK) != 0){
// if(!verify_file(path))
// {
// return -1;
// }
// status = mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
// if (status != 0) {
// return -1;
// }
// }
memset(path, 0, sizeof(path));
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
@ -460,9 +450,6 @@ int kdk_system_set_24_timeformat()
char *homeDir = NULL;
int status = 0;
// homeDir = getenv("HOME");
// sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
char canonical_filename[PATH_MAX] = "\0";
homeDir = getenv("HOME");
@ -506,9 +493,6 @@ int kdk_system_set_12_timeformat()
GError *gerr = NULL;
int status = 0;
// homeDir = getenv("HOME");
// sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
char canonical_filename[PATH_MAX] = "\0";
homeDir = getenv("HOME");
@ -1757,16 +1741,6 @@ int kdk_system_set_long_dateformat(char *format)
}
}
// if(access(path,F_OK) != 0){
// if(!verify_file(path))
// {
// return -1;
// }
// status = mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
// if (status != 0) {
// return -1;
// }
// }
memset(path, 0, sizeof(path));
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
@ -1880,16 +1854,6 @@ int kdk_system_set_short_dateformat(char *format)
}
}
// if(access(path,F_OK) != 0){
// if(!verify_file(path))
// {
// return -1;
// }
// status = mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
// if (status != 0) {
// return -1;
// }
// }
memset(path, 0, sizeof(path));
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
char tpath[100] = {0};
@ -1903,45 +1867,23 @@ int kdk_system_set_short_dateformat(char *format)
{
len = strlen(tmp);
sdate = strtok_short_date(tmp, "/");
printf("len = %d, sdate = %d\n", len, sdate);
if(len == 10)
{
// if(mark == 1)
// {
// if(sdate == 4)
// {
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yyyy/MM/dd");
// }else{
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "MM/dd/yyyy");
// }
// }
// else{
if(sdate == 4)
{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yyyy/MM/dd");
}else{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "MM/dd/yyyy");
}
// }
}
else {
// if(mark == 1)
// {
// if(sdate == 2)
// {
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yy/M/d");
// }else{
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "M/d/yy");
// }
// }
// else{
if(sdate == 2)
{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yy/M/d");
}else{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "M/d/yy");
}
// }
}
}
else if(strstr(tmp, "-"))
@ -1950,42 +1892,20 @@ int kdk_system_set_short_dateformat(char *format)
sdate = strtok_short_date(tmp, "-");
if(len == 10)
{
// if(mark == 1)
// {
// if(sdate == 4)
// {
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yyyy-MM-dd");
// }else{
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "MM-dd-yyyy");
// }
// }
// else{
if(sdate == 4)
{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yyyy-MM-dd");
}else{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "MM-dd-yyyy");
}
// }
}
else {
// if(mark == 1)
// {
// if(sdate == 2)
// {
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yy-M-d");
// }else{
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "M-d-yy");
// }
// }
// else{
if(sdate == 2)
{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yy-M-d");
}else{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "M-d-yy");
}
// }
}
}
else if(strstr(tmp, "."))
@ -1994,42 +1914,20 @@ int kdk_system_set_short_dateformat(char *format)
sdate = strtok_short_date(tmp, ".");
if(len == 10)
{
// if(mark == 1)
// {
// if(sdate == 4)
// {
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yyyy.MM.dd");
// }else{
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "MM.dd.yyyy");
// }
// }
// else{
if(sdate == 4)
{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yyyy.MM.dd");
}else{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "MM.dd.yyyy");
}
// }
}
else {
// if(mark == 1)
// {
// if(sdate == 2)
// {
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yy.M.d");
// }else{
// g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "M.d.yy");
// }
// }
// else{
if(sdate == 2)
{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "yy.M.d");
}else{
g_key_file_set_value(config, DATEFORMAT, "SHORT_DATE_FORMAT", "M.d.yy");
}
// }
}
}
g_key_file_save_to_file(config, path, &gerr);
@ -2295,9 +2193,6 @@ char* kdk_system_get_longformat()
char* kdk_system_get_shortformat()
{
// setlocale (LC_ALL, "");
// bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
// textdomain (GETTEXT_PACKAGE);
char *homeDir = NULL;
char *value = NULL;
char *tvalue = malloc(sizeof(char) * 32);
@ -2446,9 +2341,6 @@ char* kdk_system_longformat_transform(struct tm *ptr)
char* kdk_system_shortformat_transform(struct tm *ptr)
{
// setlocale (LC_ALL, "");
// bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
// textdomain (GETTEXT_PACKAGE);
char *homeDir = NULL;
char value[32] = "\0";
char *tvalue = (char *)malloc(sizeof(char) * 64);
@ -2624,7 +2516,6 @@ kdk_logn_dateinfo *kdk_system_login_lock_dateinfo(char *user)
if(strstr(lang, "en"))
{
// strftime(tmp, sizeof(tmp), "%I:%M %p", localtime(&current));
if (ap_time == 0)
{
strftime(tmp, sizeof(tmp), "%I:%M AM", localtime(&current));