From owner-freebsd-questions@FreeBSD.ORG Thu Aug 25 10:36:02 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A7101065674 for ; Thu, 25 Aug 2011 10:36:02 +0000 (UTC) (envelope-from tzhuan@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 465978FC1A for ; Thu, 25 Aug 2011 10:36:02 +0000 (UTC) Received: by vws18 with SMTP id 18so2460618vws.13 for ; Thu, 25 Aug 2011 03:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=jXDsRRMdrnKA5CJ+sZegWY4hR6dCFp7Cw3UE3HG4puI=; b=LUM+dxmj1yTdQSQuN6+NZaSGF7Y9ZamIrRxtnLbKC09EU+gI0myi6hQJeD4xhu26sh iSRlRtx3EHxmh2xSiDnYVsQ/xduwiLluoLmk6C0FfffcsqmtFNIKg6JDGGTjB1dXCNqd d4VoCLt3gmTgClrRtEA80YdsoQa4iUJ4Zsu7w= Received: by 10.52.92.83 with SMTP id ck19mr3594748vdb.81.1314267038287; Thu, 25 Aug 2011 03:10:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.161.234 with HTTP; Thu, 25 Aug 2011 03:10:18 -0700 (PDT) From: Tz-Huan Huang Date: Thu, 25 Aug 2011 18:10:18 +0800 Message-ID: To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=UTF-8 Subject: mkdir and umask on FreeBSD 7.2-RELEASE-p8 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Aug 2011 10:36:02 -0000 (Please CC. me because I'm not in freebsd-question@, thanks.) We have a ftp site runs pure-ftpd-1.0.32 on a FreeBSD 7.2-RELEASE-p8 i386 box. (I know 7.2 is very old, but that machine doesn't boot on later version...) We find that the permission of newly created directory/files are always 750 and 640 (we set the umask to 022/133 for dir/file in pure-ftpd). I try to trace the codes to figure it out. In order to find the problem, I add some codes to print more information. Here is the code for making a directory (FTP command MKD): /* my codes for debugging */ fprintf(stderr, "getuid: %d\n", getuid()); fprintf(stderr, "original umask: %o\n", umask((mode_t)0)); fprintf(stderr, "umask: %o, mode: %o\n", u_mask_d, 0777 & ~u_mask_d); /* end of my codes */ if ((mkdir(name, (mode_t) (0777 & ~u_mask_d))) < 0) { #ifdef QUOTAS (void) quota_update("a, -1LL, 0LL, NULL); #endif error(550, MSG_MKD_FAILURE); } else { addreply(257, "\"%s\" : " MSG_MKD_SUCCESS, name); #ifndef MINIMAL cwd_failures = 0UL; #endif } /* my codes for debugging */ struct stat *tmp; stat(name, tmp); fprintf(stderr, "st_mode: %o\n", tmp->st_mode); /* end of my code */ When making the dir via ftp, the output is getuid: 7000 original umask: 0 umask: 22, mode: 755 st_mode: 40750 I'm curious that why the st_mode is 750 not 755? Is it normal or do I miss something? Thanks! Tz-Huan