3
3
structures are created.
4
4
*/
5
5
6
- #ifndef _ANDROID_PASSWD_GROUP
7
- #define _ANDROID_PASSWD_GROUP
8
-
9
6
#include <stdio.h>
10
- #include <unistd.h>
11
- #include <stdlib.h>
12
7
#include <string.h>
13
8
#include <ctype.h>
9
+ #include "android_ids.h"
14
10
#include "android_passwd_group.h"
15
11
16
12
struct android_id_info * find_android_id_info_by_id (unsigned id ) {
@@ -67,7 +63,7 @@ int is_valid_id_android(id_t id, int is_group) {
67
63
return 0 ;
68
64
}
69
65
70
- static id_t oem_id_from_name_android (const char * name ) {
66
+ id_t oem_id_from_name_android (const char * name ) {
71
67
unsigned int id ;
72
68
if (sscanf (name , "oem_%u" , & id ) != 1 ) {
73
69
return 0 ;
@@ -78,7 +74,7 @@ static id_t oem_id_from_name_android(const char* name) {
78
74
return (id_t )id ;
79
75
}
80
76
81
- static id_t app_id_from_name_android (const char * name , int is_group ) {
77
+ id_t app_id_from_name_android (const char * name , int is_group ) {
82
78
char * end ;
83
79
unsigned long userid ;
84
80
struct android_id_info * info ;
@@ -87,7 +83,7 @@ static id_t app_id_from_name_android(const char* name, int is_group) {
87
83
if (is_group && name [0 ] == 'a' && name [1 ] == 'l' && name [2 ] == 'l' ) {
88
84
end = malloc (strlen (name ));
89
85
for (int i = 3 ; i < strlen (name ); i ++ )
90
- sprintf (end , "%s%c" , end , name [i ]);
86
+ strncat (end , & name [i ], 1 );
91
87
userid = 0 ;
92
88
is_shared_gid = 1 ;
93
89
} else if (name [0 ] == 'u' && isdigit (name [1 ])) {
@@ -186,27 +182,27 @@ void get_name_by_gid_android(gid_t gid, char *name_g) {
186
182
}
187
183
}
188
184
189
- struct passwd * get_passwd_android (char * name , uid_t uid ) {
185
+ struct passwd * get_passwd_android (const char * name , uid_t uid ) {
190
186
static struct passwd res ;
191
187
192
- res .pw_name = name ;
193
- res .pw_passwd = "*" ;
188
+ res .pw_name = ( char * ) name ;
189
+ res .pw_passwd = ( char * ) "*" ;
194
190
res .pw_uid = uid ;
195
191
res .pw_gid = uid ;
196
- res .pw_gecos = "" ;
197
- res .pw_dir = APP_HOME_DIR ;
198
- res .pw_shell = APP_PREFIX_DIR "/bin/login" ;
192
+ res .pw_gecos = ( char * ) "" ;
193
+ res .pw_dir = ( char * ) APP_HOME_DIR ;
194
+ res .pw_shell = ( char * )( APP_PREFIX_DIR "/bin/login" ) ;
199
195
200
196
return & res ;
201
197
}
202
198
203
- struct group * get_group_android (char * name , gid_t gid ) {
199
+ struct group * get_group_android (const char * name , gid_t gid ) {
204
200
static struct group res ;
205
201
206
- res .gr_name = name ;
202
+ res .gr_name = ( char * ) name ;
207
203
res .gr_passwd = NULL ;
208
204
res .gr_gid = gid ;
209
- res .gr_mem = (char * [2 ]){(char * )name , NULL };
205
+ res .gr_mem = * (char * * [2 ]){(char * * )name , NULL };
210
206
211
207
return & res ;
212
208
}
@@ -243,7 +239,7 @@ struct group * getgrgid_android(gid_t gid) {
243
239
return get_group_android (name_res , gid );
244
240
}
245
241
246
- struct passwd * getpwnam_android (char * name ) {
242
+ struct passwd * getpwnam_android (const char * name ) {
247
243
uid_t uid ;
248
244
struct android_id_info * info ;
249
245
@@ -262,7 +258,7 @@ struct passwd * getpwnam_android(char* name) {
262
258
return NULL ;
263
259
}
264
260
265
- struct group * getgrnam_android (char * name ) {
261
+ struct group * getgrnam_android (const char * name ) {
266
262
gid_t gid ;
267
263
struct android_id_info * info ;
268
264
@@ -280,5 +276,3 @@ struct group * getgrnam_android(char* name) {
280
276
281
277
return NULL ;
282
278
}
283
-
284
- #endif // _ANDROID_PASSWD_GROUP
0 commit comments