Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
83af542d
Commit
83af542d
authored
Jan 10, 2014
by
antma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
close /etc/passwd file handle right after evaluating home directory
parent
3795a776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
main.c
main.c
+11
-2
No files found.
main.c
View file @
83af542d
...
@@ -120,16 +120,25 @@ void set_terminal_attributes (void) {
...
@@ -120,16 +120,25 @@ void set_terminal_attributes (void) {
/* }}} */
/* }}} */
char
*
get_home_directory
(
void
)
{
char
*
get_home_directory
(
void
)
{
static
char
*
home_directory
=
NULL
;
if
(
home_directory
!=
NULL
)
{
return
home_directory
;
}
struct
passwd
*
current_passwd
;
struct
passwd
*
current_passwd
;
uid_t
user_id
;
uid_t
user_id
;
setpwent
();
setpwent
();
user_id
=
getuid
();
user_id
=
getuid
();
while
((
current_passwd
=
getpwent
()))
{
while
((
current_passwd
=
getpwent
()))
{
if
(
current_passwd
->
pw_uid
==
user_id
)
{
if
(
current_passwd
->
pw_uid
==
user_id
)
{
return
current_passwd
->
pw_dir
;
home_directory
=
tstrdup
(
current_passwd
->
pw_dir
);
break
;
}
}
}
}
return
""
;
endpwent
();
if
(
home_directory
==
NULL
)
{
home_directory
=
tstrdup
(
"."
);
}
return
home_directory
;
}
}
char
*
get_config_directory
(
void
)
{
char
*
get_config_directory
(
void
)
{
...
...
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