diff --git a/fsutils/passwd/Makefile b/fsutils/passwd/Makefile index 14ff23932..3b99759ba 100644 --- a/fsutils/passwd/Makefile +++ b/fsutils/passwd/Makefile @@ -3,7 +3,7 @@ # # Copyright (C) 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: diff --git a/fsutils/passwd/passwd.h b/fsutils/passwd/passwd.h index 1a04475d5..57c3427aa 100644 --- a/fsutils/passwd/passwd.h +++ b/fsutils/passwd/passwd.h @@ -71,7 +71,7 @@ struct passwd_s /**************************************************************************** * Name: passwd_lock and passwd_unlock * - * Description: + * Description: * Lock the /etc/passwd file. This is not a real lock at the level of the * file system. Rather, it only prevents concurrent modification of the * /etc/passwd file by passwd_adduser(), passwd_deluser(), and @@ -97,7 +97,7 @@ int passwd_unlock(FAR sem_t *sem); /**************************************************************************** * Name: passwd_encrypt * - * Description: + * Description: * Encrypt a password. Currently uses the Tiny Encryption Algorithm. * * Input Parameters: @@ -114,7 +114,7 @@ int passwd_encrypt(FAR const char *password, char encrypted[MAX_ENCRYPTED + 1]); /**************************************************************************** * Name: passwd_append * - * Description: + * Description: * Append a new record to the end of the /etc/passwd file * * Input Parameters: @@ -130,7 +130,7 @@ int passwd_append(FAR const char *username, FAR const char *password); /**************************************************************************** * Name: passwd_delete * - * Description: + * Description: * Delete on record from the password file at offset. * * Input Parameters: @@ -146,8 +146,8 @@ int passwd_delete(off_t offset); /**************************************************************************** * Name: passwd_find * - * Description: - * Find a password in the + * Description: + * Find a password in the * * Input Parameters: * diff --git a/fsutils/passwd/passwd_adduser.c b/fsutils/passwd/passwd_adduser.c index e8a0946ba..e8f8c4656 100644 --- a/fsutils/passwd/passwd_adduser.c +++ b/fsutils/passwd/passwd_adduser.c @@ -50,7 +50,7 @@ /**************************************************************************** * Name: passwd_adduser * - * Description: + * Description: * Add a new user to the /etc/passwd file. If the user already exists, * then this function will fail with -EEXIST. * @@ -98,7 +98,7 @@ int passwd_adduser(FAR const char *username, FAR const char *password) /* Return success */ ret = OK; - + errout_with_lock: (void)passwd_unlock(sem); return ret; diff --git a/fsutils/passwd/passwd_append.c b/fsutils/passwd/passwd_append.c index 6581c15c1..12e27093f 100644 --- a/fsutils/passwd/passwd_append.c +++ b/fsutils/passwd/passwd_append.c @@ -50,7 +50,7 @@ /**************************************************************************** * Name: passwd_append * - * Description: + * Description: * Append a new record to the end of the /etc/passwd file * * Input Parameters: @@ -97,7 +97,7 @@ int passwd_append(FAR const char *username, FAR const char *password) /* Return success */ ret = OK; - + errout_with_stream: (void)fclose(stream); return ret; diff --git a/fsutils/passwd/passwd_delete.c b/fsutils/passwd/passwd_delete.c index 0a795d123..27b1caa56 100644 --- a/fsutils/passwd/passwd_delete.c +++ b/fsutils/passwd/passwd_delete.c @@ -54,7 +54,7 @@ /**************************************************************************** * Name: passwd_copyfile * - * Description: + * Description: * Copy copysize from instream to outstream (or until an error or EOF is * encountered) * @@ -157,7 +157,7 @@ static int passwd_copyfile(FAR char *iobuffer, FILE *instream, /**************************************************************************** * Name: passwd_delete * - * Description: + * Description: * Delete on record from the password file at offset. * * Input Parameters: @@ -248,7 +248,7 @@ int passwd_delete(off_t offset) break; } } - + /* Copy the rest of the file */ ret = passwd_copyfile(iobuffer, instream, outstream, SIZE_MAX); diff --git a/fsutils/passwd/passwd_deluser.c b/fsutils/passwd/passwd_deluser.c index 870b2b5b0..0604acc50 100644 --- a/fsutils/passwd/passwd_deluser.c +++ b/fsutils/passwd/passwd_deluser.c @@ -50,7 +50,7 @@ /**************************************************************************** * Name: passwd_deluser * - * Description: + * Description: * Remove an existing user from the /etc/passwd file. If the user does * not exist, then this function will fail. * diff --git a/fsutils/passwd/passwd_encrypt.c b/fsutils/passwd/passwd_encrypt.c index 89c8703ea..4b6f39e79 100644 --- a/fsutils/passwd/passwd_encrypt.c +++ b/fsutils/passwd/passwd_encrypt.c @@ -68,7 +68,7 @@ static uint32_t g_tea_key[4] = /**************************************************************************** * Name: passwd_encrypt * - * Description: + * Description: * Encrypt a password. Currently uses the Tiny Encryption Algorithm. * * Input Parameters: diff --git a/fsutils/passwd/passwd_find.c b/fsutils/passwd/passwd_find.c index b71d75efe..3bae9f8df 100644 --- a/fsutils/passwd/passwd_find.c +++ b/fsutils/passwd/passwd_find.c @@ -53,8 +53,8 @@ /**************************************************************************** * Name: passwd_find * - * Description: - * Find a password in the + * Description: + * Find a password in the * * Input Parameters: * diff --git a/fsutils/passwd/passwd_lock.c b/fsutils/passwd/passwd_lock.c index dcd586222..1990a1b72 100644 --- a/fsutils/passwd/passwd_lock.c +++ b/fsutils/passwd/passwd_lock.c @@ -1,48 +1,48 @@ -/**************************************************************************** - * apps/fsutils/passwd/passwd_lock.c - * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include "passwd.h" - +/**************************************************************************** + * apps/fsutils/passwd/passwd_lock.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include "passwd.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -73,7 +73,7 @@ static sem_t g_passwd_sem = SEM_INITIALIZER(1); /**************************************************************************** * Name: passwd_lock and passwd_unlock * - * Description: + * Description: * Lock the /etc/passwd file. This is not a real lock at the level of the * file system. Rather, it only prevents concurrent modification of the * /etc/passwd file by passwd_adduser(), passwd_deluser(), and @@ -116,7 +116,7 @@ int passwd_lock(FAR sem_t **semp) DEBUGASSERT(errcode == EINTR); UNUSED(errcode); } - + *semp = sem; return OK; } @@ -131,7 +131,7 @@ int passwd_unlock(FAR sem_t *sem) /* Close the named semaphore */ (void)sem_close(sem); -#endif - +#endif + return OK; } diff --git a/fsutils/passwd/passwd_update.c b/fsutils/passwd/passwd_update.c index de7754e81..8f54d9acc 100644 --- a/fsutils/passwd/passwd_update.c +++ b/fsutils/passwd/passwd_update.c @@ -49,7 +49,7 @@ /**************************************************************************** * Name: passwd_update * - * Description: + * Description: * Change a new user to the /etc/passwd file. If the user does not exist, * then this function will fail. * diff --git a/fsutils/passwd/passwd_verify.c b/fsutils/passwd/passwd_verify.c index 07899f448..139109760 100644 --- a/fsutils/passwd/passwd_verify.c +++ b/fsutils/passwd/passwd_verify.c @@ -50,7 +50,7 @@ /**************************************************************************** * Name: passwd_verify * - * Description: + * Description: * Return true if the username exists in the /etc/passwd file and if the * password matches the user password in that faile. * diff --git a/include/fsutils/passwd.h b/include/fsutils/passwd.h index 0850621e2..3374b2571 100644 --- a/include/fsutils/passwd.h +++ b/include/fsutils/passwd.h @@ -1,118 +1,118 @@ -/**************************************************************************** - * apps/include/fsutils/passwd.h - * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __APPS_INCLUDE_FSUTILS_PASSWD_H -#define __APPS_INCLUDE_FSUTILS_PASSWD_H 1 - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: passwd_adduser - * - * Description: - * Add a new user to the /etc/passwd file. If the user already exists, - * then this function will fail with -EEXIST. - * - * Input Parameters: - * - * Returned Value: - * Zero (OK) is returned on success; a negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int passwd_adduser(FAR const char *username, FAR const char *password); - -/**************************************************************************** - * Name: passwd_deluser - * - * Description: - * Remove an existing user from the /etc/passwd file. If the user does - * not exist, then this function will fail. - * - * Input Parameters: - * - * Returned Value: - * Zero (OK) is returned on success; a negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int passwd_deluser(FAR const char *username, FAR const char *password); - -/**************************************************************************** - * Name: passwd_update - * - * Description: - * Change a new user to the /etc/passwd file. If the user does not exist, - * then this function will fail. - * - * Input Parameters: - * - * Returned Value: - * Zero (OK) is returned on success; a negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int passwd_update(FAR const char *username, FAR const char *password); - -/**************************************************************************** - * Name: passwd_verify - * - * Description: - * Return true if the username exists in the /etc/passwd file and if the - * password matches the user password in that faile. - * - * Input Parameters: - * - * Returned Value: - * One (1) is returned on success match, Zero (OK) is returned on an - * unsuccessful match; a negated errno value is returned on any other - * failure. - * - ****************************************************************************/ - -int passwd_verify(FAR const char *username, FAR const char *password); - -#endif /* __APPS_INCLUDE_FSUTILS_PASSWD_H */ +/**************************************************************************** + * apps/include/fsutils/passwd.h + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __APPS_INCLUDE_FSUTILS_PASSWD_H +#define __APPS_INCLUDE_FSUTILS_PASSWD_H 1 + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: passwd_adduser + * + * Description: + * Add a new user to the /etc/passwd file. If the user already exists, + * then this function will fail with -EEXIST. + * + * Input Parameters: + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * failure. + * + ****************************************************************************/ + +int passwd_adduser(FAR const char *username, FAR const char *password); + +/**************************************************************************** + * Name: passwd_deluser + * + * Description: + * Remove an existing user from the /etc/passwd file. If the user does + * not exist, then this function will fail. + * + * Input Parameters: + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * failure. + * + ****************************************************************************/ + +int passwd_deluser(FAR const char *username, FAR const char *password); + +/**************************************************************************** + * Name: passwd_update + * + * Description: + * Change a new user to the /etc/passwd file. If the user does not exist, + * then this function will fail. + * + * Input Parameters: + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * failure. + * + ****************************************************************************/ + +int passwd_update(FAR const char *username, FAR const char *password); + +/**************************************************************************** + * Name: passwd_verify + * + * Description: + * Return true if the username exists in the /etc/passwd file and if the + * password matches the user password in that faile. + * + * Input Parameters: + * + * Returned Value: + * One (1) is returned on success match, Zero (OK) is returned on an + * unsuccessful match; a negated errno value is returned on any other + * failure. + * + ****************************************************************************/ + +int passwd_verify(FAR const char *username, FAR const char *password); + +#endif /* __APPS_INCLUDE_FSUTILS_PASSWD_H */