diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/computer.c | 29 | ||||
| -rw-r--r-- | modules/computer/os.c | 24 | 
2 files changed, 48 insertions, 5 deletions
diff --git a/modules/computer.c b/modules/computer.c index e3976e81..7bb470a3 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -43,6 +43,7 @@  /* Callbacks */  gchar *callback_summary(void);  gchar *callback_os(void); +gchar *callback_security(void);  gchar *callback_modules(void);  gchar *callback_boots(void);  gchar *callback_locales(void); @@ -59,6 +60,7 @@ gchar *callback_dev(void);  /* Scan callbacks */  void scan_summary(gboolean reload);  void scan_os(gboolean reload); +void scan_security(gboolean reload);  void scan_modules(gboolean reload);  void scan_boots(gboolean reload);  void scan_locales(gboolean reload); @@ -75,6 +77,7 @@ void scan_dev(gboolean reload);  static ModuleEntry entries[] = {      {N_("Summary"), "summary.png", callback_summary, scan_summary, MODULE_FLAG_NONE},      {N_("Operating System"), "os.png", callback_os, scan_os, MODULE_FLAG_NONE}, +    {N_("Security"), "os.png", callback_security, scan_security, MODULE_FLAG_NONE},      {N_("Kernel Modules"), "module.png", callback_modules, scan_modules, MODULE_FLAG_NONE},      {N_("Boots"), "boot.png", callback_boots, scan_boots, MODULE_FLAG_NONE},      {N_("Languages"), "language.png", callback_locales, scan_locales, MODULE_FLAG_NONE}, @@ -143,6 +146,13 @@ void scan_os(gboolean reload)      SCAN_END();  } +void scan_security(gboolean reload) +{ +    SCAN_START(); +    //nothing to do here yet +    SCAN_END(); +} +  void scan_modules(gboolean reload)  {      SCAN_START(); @@ -512,11 +522,6 @@ gchar *callback_os(void)          info_field(_("Desktop Environment"), computer->os->desktop),          info_field_last()); -    info_add_group(info, _("Security"), -        info_field_update(_("Available entropy in /dev/random"), 1000), -        info_field(_("ASLR"), idle_free(computer_get_aslr())), -        info_field_last()); -      info_add_group(info, _("Misc"),          info_field_update(_("Uptime"), 1000),          info_field_update(_("Load Average"), 10000), @@ -525,6 +530,20 @@ gchar *callback_os(void)      return info_flatten(info);  } +gchar *callback_security(void) +{ +    struct Info *info = info_new(); + +    info_add_group(info, _("Security"), +        info_field(_("HardInfo running as"), (getuid() == 0) ? _("Superuser") : _("User")), +        info_field_update(_("Available entropy in /dev/random"), 1000), +        info_field(_("ASLR"), idle_free(computer_get_aslr())), +        info_field(_("dmesg"), idle_free(computer_get_dmesg_status())), +        info_field_last()); + +    return info_flatten(info); +} +  gchar *callback_modules(void)  {      struct Info *info = info_new(); diff --git a/modules/computer/os.c b/modules/computer/os.c index 7a8348f2..49210307 100644 --- a/modules/computer/os.c +++ b/modules/computer/os.c @@ -263,6 +263,29 @@ detect_desktop_environment(void)  }  gchar * +computer_get_dmesg_status(void) +{ +    gchar *out = NULL, *err = NULL; +    int ex = 1, result = 0; +    g_spawn_command_line_sync("dmesg", &out, &err, &ex, NULL); +    g_free(out); +    g_free(err); +    result += (getuid() == 0) ? 2 : 0; +    result += ex ? 1 : 0; +    switch(result) { +        case 0: /* readable, user */ +            return g_strdup(_("User access allowed")); +        case 1: /* unreadable, user */ +            return g_strdup(_("User access forbidden")); +        case 2: /* readable, root */ +            return g_strdup(_("Access allowed (running as superuser)")); +        case 3: /* unreadable, root */ +            return g_strdup(_("Access forbidden? (running as superuser)")); +    } +    return g_strdup(_("(Unknown)")); +} + +gchar *  computer_get_aslr(void)  {      switch (h_sysfs_read_int("/proc/sys/kernel", "randomize_va_space")) { @@ -276,6 +299,7 @@ computer_get_aslr(void)          return g_strdup(_("Unknown"));      }  } +  gchar *  computer_get_entropy_avail(void)  {  | 
