From owner-freebsd-hackers@freebsd.org Tue Apr 27 08:41:45 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7EF18625B6D for ; Tue, 27 Apr 2021 08:41:45 +0000 (UTC) (envelope-from 6yearold@gmail.com) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FTwGw5yJRz3h3j for ; Tue, 27 Apr 2021 08:41:44 +0000 (UTC) (envelope-from 6yearold@gmail.com) Received: by mail-lj1-f182.google.com with SMTP id s9so9366151ljj.6 for ; Tue, 27 Apr 2021 01:41:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=DZjswjYmjsBFvbZKVUi3/qvOyGWDaWagV1vuh1AMNso=; b=puUKr1F+9GgJPSPFa9z4r80cjPxI+ZTtUhGHrQxcqlSUTaRlcrUrdh265C4wV/C3Bz gY/tVpHTy7yExMFiG9ju0CgOO16EsqK8d0dvizwWF8CNqH3PPqJzJx+gDNJRu8kXCaHE b/84M0lMDGC/cZgTz3kGkkdHfLoeMjbTuxWiC77igW40j+P8Y5Xet4uWIGMT7p3gqygu HCDIStMpuv5BJUjyEJ98nE5MgW0MRIGqkcptm4UyLNOPjz/pKCLrkY5xZyxT4E4R6DB/ g6OFNP1sCFIqdQ2ekWyOR1lJ46T5r9/1GrXPj9N+F0psg4T72BAyEUOWjmk2xISwIuSW ptpg== X-Gm-Message-State: AOAM530oTWK9+cPNst1Om1b1dD7mV0VTgH5gaBLkkOpFgqZH1MZwqggA PAlk9uFHFxcFTtGukrMYbwsNsBdDY/0RMQ== X-Google-Smtp-Source: ABdhPJxE1On9R81ADPNu3v1ZGNBmSny61zV+BGMNPAJZ00IexrIPn/h1HKTpdF1dVkTMxPvEyS42WA== X-Received: by 2002:a2e:a369:: with SMTP id i9mr15934144ljn.273.1619512902906; Tue, 27 Apr 2021 01:41:42 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id x12sm1661204lfe.123.2021.04.27.01.41.42 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Apr 2021 01:41:42 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id x19so62125400lfa.2 for ; Tue, 27 Apr 2021 01:41:42 -0700 (PDT) X-Received: by 2002:a05:6512:b25:: with SMTP id w37mr16078241lfu.272.1619512902231; Tue, 27 Apr 2021 01:41:42 -0700 (PDT) MIME-Version: 1.0 From: Gleb Popov Date: Tue, 27 Apr 2021 11:41:16 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: ACLs are not reflected in FS extended attributes To: freebsd-hackers X-Rspamd-Queue-Id: 4FTwGw5yJRz3h3j X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of 6yearold@gmail.com designates 209.85.208.182 as permitted sender) smtp.mailfrom=6yearold@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.998]; FORGED_SENDER(0.30)[arrowd@freebsd.org,6yearold@gmail.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FROM_NEQ_ENVFROM(0.00)[arrowd@freebsd.org,6yearold@gmail.com]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.208.182:from]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TO_DOM_EQ_FROM_DOM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[209.85.208.182:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[209.85.208.182:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.208.182:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2021 08:41:45 -0000 Hello hackers. I'm trying to implement Linux acl_extended_file() function [1] within our libc. On Linux this function is implemented via getxattr, a function that reads extended attributes from the file [2][3] My implementation follows the Linux one: int acl_extended_file_np(const char *path_p) { return _acl_extended_file(extattr_get_file, path_p); } int _acl_extended_file(getattr_func f, const char* path_p) { int base_size = 9999; // figure out this later int retval; retval = f(path_p, POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE, POSIX1E_ACL_ACCESS_EXTATTR_NAME, NULL, 0); printf("Retval1: %d\n", retval); if (retval < 0 && errno != ENOATTR) return -1; if (retval > base_size) return 1; retval = f(path_p, POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE, POSIX1E_ACL_DEFAULT_EXTATTR_NAME, NULL, 0); printf("Retval2: %d\n", retval); if (retval < 0 && errno != ENOATTR) return -1; if (retval > base_size) return 1; return 0; } However, when I tried to use it, I stumbled upon following differences: - It requires root permissions to operate. I guess this is because it tries to look at "system" extattr namespace. - It doesn't work anyways due to "Attribute not found" error. And indeed, the same behavior can be seen when using command line tools. On Linux: $ setfacl -m u:someuser:rwx somefile $ getfattr -d -m - somefile system.posix_acl_access= On FreeBSD: $ setfacl -m u:someuser:rwx:allow somefile $ sudo getextattr system posix1e.acl_access somefile failed: Attribute not found I guess that FreeBSD behaviour is actually not a bug and libacl just uses some internal knowledge about how ACL/xattr is implemented on Linux. If this is correct, how should I approach implementing this function on FreeBSD? Thanks in advance. [1] https://linux.die.net/man/3/acl_extended_file [2] http://git.savannah.nongnu.org/cgit/acl.git/tree/libacl/acl_extended_file.c [3] http://git.savannah.nongnu.org/cgit/acl.git/tree/libacl/__acl_extended_file.c