aboutsummaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2018-10-30 15:53:50 +0100
committerJakub Jelen <jjelen@redhat.com>2018-10-30 16:22:17 +0100
commit9c4baa7fd58b9e4d9cdab4a03d18dd03e0e587ab (patch)
tree98b43fd5c129d094ad84acadefad46c86a4dcd05 /src/misc.c
parenta4342b97d6043ca9fee628b7675b977ff53e6db9 (diff)
downloadlibssh-9c4baa7fd58b9e4d9cdab4a03d18dd03e0e587ab.tar.gz
libssh-9c4baa7fd58b9e4d9cdab4a03d18dd03e0e587ab.tar.xz
libssh-9c4baa7fd58b9e4d9cdab4a03d18dd03e0e587ab.zip
misc: Reformat ssh_get_user_home_dir and ssh_file_readaccess_ok
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/misc.c b/src/misc.c
index 402ece41..90b63330 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -213,39 +213,42 @@ int ssh_is_ipaddr(const char *str) {
#define NSS_BUFLEN_PASSWD 4096
#endif /* NSS_BUFLEN_PASSWD */
-char *ssh_get_user_home_dir(void) {
- char *szPath = NULL;
- struct passwd pwd;
- struct passwd *pwdbuf;
- char buf[NSS_BUFLEN_PASSWD] = {0};
- int rc;
-
- rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
- if (rc != 0) {
- szPath = getenv("HOME");
- if (szPath == NULL) {
- return NULL;
- }
- snprintf(buf, sizeof(buf), "%s", szPath);
-
- return strdup(buf);
- }
+char *ssh_get_user_home_dir(void)
+{
+ char *szPath = NULL;
+ struct passwd pwd;
+ struct passwd *pwdbuf;
+ char buf[NSS_BUFLEN_PASSWD] = {0};
+ int rc;
+
+ rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
+ if (rc != 0) {
+ szPath = getenv("HOME");
+ if (szPath == NULL) {
+ return NULL;
+ }
+ snprintf(buf, sizeof(buf), "%s", szPath);
- szPath = strdup(pwd.pw_dir);
+ return strdup(buf);
+ }
+
+ szPath = strdup(pwd.pw_dir);
- return szPath;
+ return szPath;
}
/* we have read access on file */
-int ssh_file_readaccess_ok(const char *file) {
- if (access(file, R_OK) < 0) {
- return 0;
- }
+int ssh_file_readaccess_ok(const char *file)
+{
+ if (access(file, R_OK) < 0) {
+ return 0;
+ }
- return 1;
+ return 1;
}
-char *ssh_get_local_username(void) {
+char *ssh_get_local_username(void)
+{
struct passwd pwd;
struct passwd *pwdbuf;
char buf[NSS_BUFLEN_PASSWD];