2016-01-20 02:22:45 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* apps/include/fsutils/passwd.h
|
|
|
|
*
|
2020-03-21 18:25:56 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2016-01-20 02:22:45 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __APPS_INCLUDE_FSUTILS_PASSWD_H
|
2020-01-31 16:18:05 +01:00
|
|
|
#define __APPS_INCLUDE_FSUTILS_PASSWD_H
|
2016-01-20 02:22:45 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-01-20 20:05:25 +01:00
|
|
|
#include <nuttx/config.h>
|
2016-01-20 02:22:45 +01:00
|
|
|
#include <nuttx/compiler.h>
|
|
|
|
|
2016-01-20 21:41:27 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* passwd_verify() return value tests */
|
|
|
|
|
|
|
|
#define PASSWORD_VERIFY_MATCH(ret) (ret == 1)
|
|
|
|
#define PASSWORD_VERIFY_NOMATCH(ret) (ret == 0)
|
|
|
|
#define PASSWORD_VERIFY_ERROR(ret) (ret < 0)
|
2016-01-20 20:05:25 +01:00
|
|
|
|
2016-01-20 02:22:45 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: passwd_adduser
|
|
|
|
*
|
2018-08-13 15:47:26 +02:00
|
|
|
* Description:
|
2016-01-20 02:22:45 +01:00
|
|
|
* Add a new user to the /etc/passwd file. If the user already exists,
|
|
|
|
* then this function will fail with -EEXIST.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
2016-01-20 16:36:07 +01:00
|
|
|
* username - Identifies the user to be added
|
|
|
|
* password - The password for the new user
|
2016-01-20 02:22:45 +01:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned on
|
|
|
|
* failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-03-21 18:25:56 +01:00
|
|
|
#if defined(CONFIG_FSUTILS_PASSWD_READONLY)
|
2016-01-20 02:22:45 +01:00
|
|
|
int passwd_adduser(FAR const char *username, FAR const char *password);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: passwd_deluser
|
|
|
|
*
|
2018-08-13 15:47:26 +02:00
|
|
|
* Description:
|
2016-01-20 02:22:45 +01:00
|
|
|
* Remove an existing user from the /etc/passwd file. If the user does
|
|
|
|
* not exist, then this function will fail.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
2016-01-20 16:36:07 +01:00
|
|
|
* username - Identifies the user to be deleted
|
2016-01-20 02:22:45 +01:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned on
|
|
|
|
* failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-01-20 16:36:07 +01:00
|
|
|
int passwd_deluser(FAR const char *username);
|
2016-01-20 02:22:45 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: passwd_update
|
|
|
|
*
|
2018-08-13 15:47:26 +02:00
|
|
|
* Description:
|
2019-08-03 18:37:27 +02:00
|
|
|
* Change a user in the /etc/passwd file. If the user does not exist,
|
2016-01-20 02:22:45 +01:00
|
|
|
* then this function will fail.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
2016-01-20 16:36:07 +01:00
|
|
|
* username - Identifies the user whose password will be updated
|
|
|
|
* password - The new password for the existing user
|
2016-01-20 02:22:45 +01:00
|
|
|
*
|
|
|
|
* 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);
|
2019-08-03 18:37:27 +02:00
|
|
|
|
2020-03-21 18:25:56 +01:00
|
|
|
#endif /* CONFIG_FSUTILS_PASSWD_READONLY */
|
2016-01-20 02:22:45 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: passwd_verify
|
|
|
|
*
|
2018-08-13 15:47:26 +02:00
|
|
|
* Description:
|
2016-01-20 02:22:45 +01:00
|
|
|
* Return true if the username exists in the /etc/passwd file and if the
|
2020-02-23 05:51:44 +01:00
|
|
|
* password matches the user password in that failed.
|
2016-01-20 02:22:45 +01:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
2016-01-20 16:36:07 +01:00
|
|
|
* username - Identifies the user whose password will be verified
|
|
|
|
* password - The password to be verified
|
2016-01-20 02:22:45 +01:00
|
|
|
*
|
|
|
|
* 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 */
|