Revert "add tzplatform_has_users_group() api" 58/36858/1 accepted/tizen_3.0.2015.q1_common tizen_3.0.2015.q1_common tizen_3.0.2015.q2_common tizen_3.0.m1_mobile tizen_3.0.m1_tv accepted/tizen/3.0.2015.q1/common/20150317.132305 accepted/tizen/common/20150316.134733 accepted/tizen/ivi/20160218.023336 accepted/tizen/mobile/20150326.005118 accepted/tizen/tv/20150324.014453 accepted/tizen/wearable/20150323.005713 submit/tizen_3.0.2015.q1_common/20150316.112029 submit/tizen_common/20150316.111955 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000002 submit/tizen_mobile/20150325.000000 submit/tizen_tv/20150320.000001 submit/tizen_wearable/20150320.000000 tizen_3.0.m1_mobile_release tizen_3.0.m1_tv_release tizen_3.0.m2.a1_mobile_release tizen_3.0.m2.a1_tv_release
authorStephane Desneux <stephane.desneux@open.eurogiciel.org>
Mon, 16 Mar 2015 11:13:51 +0000 (12:13 +0100)
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>
Mon, 16 Mar 2015 11:15:16 +0000 (12:15 +0100)
This reverts commit 7cc9610e72221a634efa565162370c60c828254b.

It was a temporary solution. should be superseeded by cynara.

Change-Id: If93304d042b087dea02e0129f1f9e82372330834

src/Makefile.am
src/build.sh
src/isadmin.c [moved from src/groups.c with 69% similarity]
src/isadmin.h [moved from src/groups.h with 67% similarity]
src/static-api.c
src/tzplatform_config.h

index 1329919..932b323 100644 (file)
@@ -31,5 +31,5 @@ dist_pkgdata_DATA = buffer.c \
                     tzplatform_get.c \
                     passwd.h \
                     passwd.c \
-                    groups.h \
-                    groups.c
+                    isadmin.h \
+                    isadmin.c
index 4b12a2e..8f76b08 100755 (executable)
@@ -15,7 +15,7 @@ d ./toolbox c > hash.inc
 d ./toolbox signup > signup.inc
 d gcc $f -c *.c
 d ld -shared --version-script=tzplatform_config.sym -o libtzplatform-shared.so buffer.o   foreign.o  heap.o  parser.o  scratch.o context.o  hashing.o  init.o  passwd.o  shared-api.o
-d ar cr libtzplatform-static.a static-api.o groups.o
+d ar cr libtzplatform-static.a static-api.o isadmin.o
 d gcc -o get tzplatform_get.o static-api.o -L. -ltzplatform-static -ltzplatform-shared
 
 
similarity index 69%
rename from src/groups.c
rename to src/isadmin.c
index 0e7ec5e..1d1d699 100644 (file)
 #include <grp.h>
 #include <pwd.h>
 
-#include "groups.h"
+#include "isadmin.h"
+#include "tzplatform_variables.h"
 #include "tzplatform_config.h"
 
-int _has_specified_group_static_(uid_t uid, enum tzplatform_variable group) {
+int _has_system_group_static_(uid_t uid) {
        
        struct passwd *userinfo = NULL;
-       struct group *groupinfo = NULL;
-       const char *grpname = NULL;
+       struct group *systemgroupinfo = NULL;
+       const char *sysgrpname = NULL;
        uid_t myuid = 0;
-       gid_t gid = 0;
+       gid_t system_gid = 0;
        gid_t *groups = NULL;
        int i, nbgroups = 0;
        
-       if (group != TZ_SYS_USER_GROUP || group != TZ_SYS_ADMIN_GROUP) {
-               fprintf( stderr, "groups ERROR: group is not valid \n");
-               return -1;
-       }
-
+       
        if(uid == -1)
                /* Get current uid */
                myuid = getuid();
        else
                myuid = uid;
        
-       /* Get the gid of the group */
-       grpname = tzplatform_getname(group);
-       if(grpname == NULL) {
-               fprintf( stderr, "groups ERROR: variable TZ_SYS_ADMIN_GROUP is NULL");
+       /* Get the gid of the group named "system" */
+       sysgrpname = tzplatform_getname(TZ_SYS_ADMIN_GROUP);
+       if(sysgrpname == NULL) {
+               fprintf( stderr, "isadmin ERROR: variable TZ_SYS_ADMIN_GROUP is NULL");
                return -1;
        }
-       groupinfo = getgrnam(grpname);
-       if(groupinfo == NULL) {
-               fprintf( stderr, "groups ERROR: cannot find group named \"%s\"\n", grpname);
+       systemgroupinfo = getgrnam(sysgrpname);
+       if(systemgroupinfo == NULL) {
+               fprintf( stderr, "isadmin ERROR: cannot find group named \"%s\"\n", sysgrpname);
                return -1;
        }
        
-       gid = groupinfo->gr_gid;
+       system_gid = systemgroupinfo->gr_gid;
        
        /* Get all the gid of the given uid */
        
@@ -81,26 +78,26 @@ int _has_specified_group_static_(uid_t uid, enum tzplatform_variable group) {
        /* Need to call this function now to get the number of group to make the
           malloc correctly sized */
        if (getgrouplist(userinfo->pw_name, userinfo->pw_gid, groups, &nbgroups) != -1) {
-               fprintf( stderr, "groups ERROR: cannot get number of groups\n");
+               fprintf( stderr, "isadmin ERROR: cannot get number of groups\n");
                return -1;
        }
        
        groups = malloc(nbgroups * sizeof (gid_t));
        if (groups == NULL) {
-               fprintf( stderr, "groups ERROR: malloc cannot allocate memory\n");
+               fprintf( stderr, "isadmin ERROR: malloc cannot allocate memory\n");
                return -1;
        }
        
        if (getgrouplist(userinfo->pw_name, userinfo->pw_gid, groups, &nbgroups) == -1) {
                free(groups);
-               fprintf( stderr, "groups ERROR: cannot get groups\n");
+               fprintf( stderr, "isadmin ERROR: cannot get groups\n");
                return -1;
        }
        
-       /* Check if the given uid is in the specified group */
+       /* Check if the given uid is in the system group */
        
        for(i = 0 ; i < nbgroups ; i++) {
-               if(groups[i] == gid) {
+               if(groups[i] == system_gid) {
                        free(groups);
                        return 1;
                }
similarity index 67%
rename from src/groups.h
rename to src/isadmin.h
index 57175fc..25ebd75 100644 (file)
 extern "C" {
 #endif
  
-#ifndef TIZEN_PLATFORM_WRAPPER_GROUPS_H
-#define TIZEN_PLATFORM_WRAPPER_GROUPS_H
-
-#include "tzplatform_variables.h"
+#ifndef TIZEN_PLATFORM_WRAPPER_ISADMIN_H
+#define TIZEN_PLATFORM_WRAPPER_ISADMIN_H
 
 /*
- * This feature aims to know if a user belongs to a specified group
+ * DISCLAIMER :
+ *  This header and its associated source file are present to maintain a 
+ * temporary solution. We need to know if an user have the privilege for
+ * a particular action.
+ * 
+ * At the end, this feature will be managed by Cynara
+ * 
  */
 
 /*
- * Return 0 if the given uid is not in the specified group.
- * Return 1 if the given uid is in the specified group.
+ * Return 0 if the given uid is not in the admin group.
+ * Return 1 if the given uid is in the admin group.
  * 
  * If you pass the -1 value to this function it will take the current uid given
  * by the POSIX function getuid();
 */
-int _has_specified_group_static_(uid_t uid, enum tzplatform_variable group);
+int _has_system_group_static_(uid_t uid);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* TIZEN_PLATFORM_WRAPPER_GROUPS_H  */
+#endif /* TIZEN_PLATFORM_WRAPPER_ISADMIN_H  */
 
index 98f5e20..d6a4e0c 100644 (file)
@@ -32,7 +32,7 @@
 #include "tzplatform_config.h"
 
 #include "shared-api.h"
-#include "groups.h"
+#include "isadmin.h"
 
 #include "signup.inc"
 
@@ -133,12 +133,7 @@ gid_t tzplatform_context_getgid(struct tzplatform_context *context, enum tzplatf
 
 int tzplatform_has_system_group(uid_t uid) 
 {
-       return _has_specified_group_static_(uid, TZ_SYS_ADMIN_GROUP);
-}
-
-int tzplatform_has_users_group(uid_t uid)
-{
-  return _has_specified_group_static_(uid, TZ_SYS_USER_GROUP);
+       return _has_system_group_static_(uid);
 }
 
 #ifdef TEST
index 12b85b0..ab998b0 100644 (file)
@@ -404,23 +404,6 @@ gid_t tzplatform_context_getgid(struct tzplatform_context *context, enum tzplatf
 extern
 int tzplatform_has_system_group(uid_t uid);
 
-/*
- Return 1 if given uid is in the regular users group (named "users")
- Return 0 if not
- Return -1 in case of error.
-
- Example:
-        tzplatform_has_users_group(1000)
-
-    will return 0 or 1 depends on right of given uid.
-
-   NOTE :
-   * If you pass the -1 value to this function it will take the current uid given
-   * by the POSIX function getuid();
-*/
-extern
-int tzplatform_has_users_group(uid_t uid);
-
 #ifdef __cplusplus
 }
 #endif