Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 286582
b: refs/heads/master
c: 9f6ed2c
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Layton authored and Steve French committed Jan 18, 2012
1 parent 43ada80 commit ea68f0a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ce91acb3acae26f4163c5a6f1f695d1a1e8d9009
refs/heads/master: 9f6ed2ca257fa8650b876377833e6f14e272848b
3 changes: 2 additions & 1 deletion trunk/include/keys/user-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/*****************************************************************************/
/*
* the payload for a key of type "user"
* the payload for a key of type "user" or "logon"
* - once filled in and attached to a key:
* - the payload struct is invariant may not be changed, only replaced
* - the payload must be read with RCU procedures or with the key semaphore
Expand All @@ -33,6 +33,7 @@ struct user_key_payload {
};

extern struct key_type key_type_user;
extern struct key_type key_type_logon;

extern int user_instantiate(struct key *key, const void *data, size_t datalen);
extern int user_update(struct key *key, const void *data, size_t datalen);
Expand Down
1 change: 1 addition & 0 deletions trunk/security/keys/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

extern struct key_type key_type_dead;
extern struct key_type key_type_user;
extern struct key_type key_type_logon;

/*****************************************************************************/
/*
Expand Down
1 change: 1 addition & 0 deletions trunk/security/keys/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ void __init key_init(void)
list_add_tail(&key_type_keyring.link, &key_types_list);
list_add_tail(&key_type_dead.link, &key_types_list);
list_add_tail(&key_type_user.link, &key_types_list);
list_add_tail(&key_type_logon.link, &key_types_list);

/* record the root user tracking */
rb_link_node(&root_key_user.node,
Expand Down
37 changes: 37 additions & 0 deletions trunk/security/keys/user_defined.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <asm/uaccess.h>
#include "internal.h"

static int logon_vet_description(const char *desc);

/*
* user defined keys take an arbitrary string as the description and an
* arbitrary blob of data as the payload
Expand All @@ -35,6 +37,24 @@ struct key_type key_type_user = {

EXPORT_SYMBOL_GPL(key_type_user);

/*
* This key type is essentially the same as key_type_user, but it does
* not define a .read op. This is suitable for storing username and
* password pairs in the keyring that you do not want to be readable
* from userspace.
*/
struct key_type key_type_logon = {
.name = "logon",
.instantiate = user_instantiate,
.update = user_update,
.match = user_match,
.revoke = user_revoke,
.destroy = user_destroy,
.describe = user_describe,
.vet_description = logon_vet_description,
};
EXPORT_SYMBOL_GPL(key_type_logon);

/*
* instantiate a user defined key
*/
Expand Down Expand Up @@ -189,3 +209,20 @@ long user_read(const struct key *key, char __user *buffer, size_t buflen)
}

EXPORT_SYMBOL_GPL(user_read);

/* Vet the description for a "logon" key */
static int logon_vet_description(const char *desc)
{
char *p;

/* require a "qualified" description string */
p = strchr(desc, ':');
if (!p)
return -EINVAL;

/* also reject description with ':' as first char */
if (p == desc)
return -EINVAL;

return 0;
}

0 comments on commit ea68f0a

Please sign in to comment.