Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
system_security
Commits
878c359d
Commit
878c359d
authored
12 years ago
by
Kenny Root
Committed by
android code review
12 years ago
Browse files
Options
Download
Plain Diff
Merge "Add getmtime command for keys"
parents
e7f9da44
344e0bc2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
keystore/keystore.cpp
keystore/keystore.cpp
+34
-0
keystore/keystore.h
keystore/keystore.h
+3
-1
No files found.
keystore/keystore.cpp
View file @
878c359d
...
...
@@ -1273,6 +1273,39 @@ static ResponseCode ungrant(KeyStore* keyStore, int, uid_t uid, Value* keyName,
return
keyStore
->
removeGrant
(
filename
,
granteeData
)
?
NO_ERROR
:
KEY_NOT_FOUND
;
}
static
ResponseCode
getmtime
(
KeyStore
*
,
int
sock
,
uid_t
uid
,
Value
*
keyName
,
Value
*
,
Value
*
)
{
char
filename
[
NAME_MAX
];
encode_key_for_uid
(
filename
,
uid
,
keyName
);
if
(
access
(
filename
,
R_OK
)
==
-
1
)
{
return
(
errno
!=
ENOENT
)
?
SYSTEM_ERROR
:
KEY_NOT_FOUND
;
}
int
fd
=
open
(
filename
,
O_NOFOLLOW
,
O_RDONLY
);
if
(
fd
<
0
)
{
return
SYSTEM_ERROR
;
}
struct
stat
s
;
int
ret
=
fstat
(
fd
,
&
s
);
close
(
fd
);
if
(
ret
==
-
1
)
{
return
SYSTEM_ERROR
;
}
uint8_t
*
data
;
int
dataLength
=
asprintf
(
reinterpret_cast
<
char
**>
(
&
data
),
"%lu"
,
s
.
st_mtime
);
if
(
dataLength
<
0
)
{
return
SYSTEM_ERROR
;
}
send_code
(
sock
,
NO_ERROR
);
send_message
(
sock
,
data
,
dataLength
);
free
(
data
);
return
NO_ERROR_RESPONSE_CODE_SENT
;
}
/* Here are the permissions, actions, users, and the main function. */
enum
perm
{
P_TEST
=
1
<<
TEST
,
...
...
@@ -1322,6 +1355,7 @@ static struct action {
{
del_key
,
CommandCodes
[
DEL_KEY
],
STATE_ANY
,
P_DELETE
,
{
KEY_SIZE
,
0
,
0
}},
{
grant
,
CommandCodes
[
GRANT
],
STATE_NO_ERROR
,
P_GRANT
,
{
KEY_SIZE
,
KEY_SIZE
,
0
}},
{
ungrant
,
CommandCodes
[
UNGRANT
],
STATE_NO_ERROR
,
P_GRANT
,
{
KEY_SIZE
,
KEY_SIZE
,
0
}},
{
getmtime
,
CommandCodes
[
GETMTIME
],
STATE_ANY
,
P_SAW
,
{
KEY_SIZE
,
0
,
0
}},
{
NULL
,
0
,
STATE_ANY
,
0
,
{
0
,
0
,
0
}},
};
...
...
This diff is collapsed.
Click to expand it.
keystore/keystore.h
View file @
878c359d
...
...
@@ -63,12 +63,13 @@ enum CommandNames {
DEL_KEY
=
16
,
GRANT
=
17
,
UNGRANT
=
18
,
GETMTIME
=
19
,
};
typedef
uint8_t
command_code_t
;
// Taken: a b c d e f g h i j k l m n o p q r s t u v w x y z
// * *
* * * * * * * * * * * * * * * *
// * *
*
* * * * * * * * * * * * * * * *
command_code_t
CommandCodes
[]
=
{
't'
,
// TEST
'g'
,
// GET
...
...
@@ -89,6 +90,7 @@ command_code_t CommandCodes[] = {
'k'
,
// DEL_KEY
'x'
,
// GRANT
'y'
,
// UNGRANT
'c'
,
// GETMTIME
};
/**
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment