aboutsummaryrefslogtreecommitdiff
path: root/src/util/profile
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1999-01-02 06:38:49 +0000
committerTheodore Tso <tytso@mit.edu>1999-01-02 06:38:49 +0000
commit760476bccf98912ae811cab3ccad2d173d62c940 (patch)
tree8f7578be7f0a5bf600093c9ecd1f95c0748a7942 /src/util/profile
parent684ac5c334c03708895ab38e9a5969ef2f10ef15 (diff)
downloadkrb5-760476bccf98912ae811cab3ccad2d173d62c940.zip
krb5-760476bccf98912ae811cab3ccad2d173d62c940.tar.gz
krb5-760476bccf98912ae811cab3ccad2d173d62c940.tar.bz2
prof_tree.c (profile_node_iterator): Make sure the pointer to the
iterator function is non-NULL before checking the magic value. prof_file.c (profile_open_file): Add ability to parse filenames that begin with "~/" and substitute it with "$HOME/". git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11096 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/profile')
-rw-r--r--src/util/profile/ChangeLog11
-rw-r--r--src/util/profile/prof_file.c16
-rw-r--r--src/util/profile/prof_tree.c2
3 files changed, 26 insertions, 3 deletions
diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog
index 554357a..0359115 100644
--- a/src/util/profile/ChangeLog
+++ b/src/util/profile/ChangeLog
@@ -1,3 +1,14 @@
+1998-12-31 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * prof_tree.c (profile_node_iterator): Make sure the pointer to
+ the iterator function is non-NULL before checking the
+ magic value.
+
+1998-12-15 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * prof_file.c (profile_open_file): Add ability to parse filenames
+ that begin with "~/" and substitute it with "$HOME/".
+
1998-12-04 Theodore Ts'o <tytso@rsts-11.mit.edu>
* prof_get.c: Add new public profile_iterator functions for
diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c
index 070cbef..fde6874 100644
--- a/src/util/profile/prof_file.c
+++ b/src/util/profile/prof_file.c
@@ -29,17 +29,29 @@ errcode_t profile_open_file(filename, ret_prof)
{
prf_file_t prf;
errcode_t retval;
+ char *home_env = 0;
+ int len;
prf = malloc(sizeof(struct _prf_file_t));
if (!prf)
return ENOMEM;
memset(prf, 0, sizeof(struct _prf_file_t));
- prf->filename = malloc(strlen(filename)+1);
+ len = strlen(filename)+1;
+ if (filename[0] == '~' && filename[1] == '/') {
+ home_env = getenv("HOME");
+ if (home_env)
+ len += strlen(home_env);
+ }
+ prf->filename = malloc(len);
if (!prf->filename) {
free(prf);
return ENOMEM;
}
- strcpy(prf->filename, filename);
+ if (home_env) {
+ strcpy(prf->filename, home_env);
+ strcat(prf->filename, filename+1);
+ } else
+ strcpy(prf->filename, filename);
prf->magic = PROF_MAGIC_FILE;
retval = profile_update_file(prf);
diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c
index ddfa08f..e8257c8 100644
--- a/src/util/profile/prof_tree.c
+++ b/src/util/profile/prof_tree.c
@@ -441,7 +441,7 @@ errcode_t profile_node_iterator(iter_p, ret_node, ret_name, ret_value)
errcode_t retval;
int skip_num = 0;
- if (iter->magic != PROF_MAGIC_ITERATOR)
+ if (!iter || iter->magic != PROF_MAGIC_ITERATOR)
return PROF_MAGIC_ITERATOR;
/*
* If the file has changed, then the node pointer is invalid,