Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=eb722ce6dc43dc7075ba1c4e16eeaca09d6795d9

commit eb722ce6dc43dc7075ba1c4e16eeaca09d6795d9
Author: James Buren <[email protected]>
Date:   Thu Sep 6 06:41:28 2012 -0500

add initial draft of postconfig module

diff --git a/src/SConstruct b/src/SConstruct
index 143f679..d9ea49b 100644
--- a/src/SConstruct
+++ b/src/SConstruct
@@ -35,5 +35,6 @@ env.Program('fwsetup',[
'main.c',
'utility.c',
'install.c',
+  'postconfig.c',
'ui_newt.c'
])
diff --git a/src/postconfig.c b/src/postconfig.c
new file mode 100644
index 0000000..81ca4a1
--- /dev/null
+++ b/src/postconfig.c
@@ -0,0 +1,80 @@
+#include "local.h"
+
+static bool is_root_setup(void)
+{
+  FILE *file = 0;
+  char line[LINE_MAX] = {0};
+  char *tmp = 0;
+  char *user = 0;
+  char *pwd = 0;
+  bool result = false;
+
+  file = fopen("/etc/shadow","rb");
+
+  if(file == 0)
+  {
+    fprintf(logfile,"%s: %s\n",__func__,strerror(errno));
+    return false;
+  }
+
+  while(fgets(line,LINE_MAX,file) != 0)
+  {
+    if((user = strtok_r(line,":",&tmp)) == 0)
+      continue;
+
+    if((pwd = strtok_r(0,":",&tmp)) == 0)
+      continue;
+
+    if(strcmp(user,"root") == 0)
+    {
+      result = (strlen(pwd) > 1);
+      break;
+    }
+  }
+
+  fclose(file);
+
+  return result;
+}
+
+static bool is_user_setup(void)
+{
+  FILE *file = 0;
+  char line[LINE_MAX] = {0};
+  char *tmp = 0;
+  char *gid = 0;
+  bool result = false;
+
+  file = fopen("/etc/passwd","rb");
+
+  if(file == 0)
+  {
+    fprintf(logfile,"%s: %s\n",__func__,strerror(errno));
+    return false;
+  }
+
+  while(fgets(line,LINE_MAX,file) != 0)
+  {
+    if(strtok_r(line,":",&tmp) == 0)
+      continue;
+
+    if(strtok_r(0,":",&tmp) == 0)
+      continue;
+
+    if(strtok_r(0,":",&tmp) == 0)
+      continue;
+
+    if((gid = strtok_r(0,":",&tmp)) == 0)
+      continue;
+
+    if(strcmp(gid,"100") == 0)
+    {
+      result = true;
+      break;
+    }
+  }
+
+  fclose(file);
+
+  return result;
+}
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to