1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include <sys/fsuid.h> 17 18#include "test.h" 19 20const gid_t fsgid = 1; 21const gid_t invalid_fsgid = -1; 22 23/** 24 * @tc.name : setfsgid_0100 25 * @tc.desc : set group identity used for filesystem checks 26 * @tc.level : Level 0 27 */ 28void setfsgid_0100(void) 29{ 30 int result = setfsgid(fsgid); 31 if (result < 0) { 32 t_error("%s failed: result = %d\n", __func__, result); 33 } 34 35 result = setfsgid(result); 36 if (result != fsgid) { 37 t_error("%s failed: result = %d\n", __func__, result); 38 } 39} 40 41/** 42 * @tc.name : setfsgid_0200 43 * @tc.desc : set an invalid group identity used for filesystem checks 44 * @tc.level : Level 2 45 */ 46void setfsgid_0200(void) 47{ 48 int result = setfsgid(invalid_fsgid); 49 if (result < 0) { 50 t_error("%s failed: result = %d\n", __func__, result); 51 } 52 53 result = setfsgid(result); 54 if (result == fsgid) { 55 t_error("%s failed: result = %d\n", __func__, result); 56 } 57} 58 59int main(int argc, char *argv[]) 60{ 61 // setfsgid_0100(); 62 // setfsgid_0200(); 63 64 return t_status; 65} 66