From patchwork Mon Jul 22 17:47:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Lovenberg X-Patchwork-Id: 2831510 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5B0DCC0319 for ; Mon, 22 Jul 2013 17:47:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 388C4202B1 for ; Mon, 22 Jul 2013 17:47:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F15D202C1 for ; Mon, 22 Jul 2013 17:47:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757059Ab3GVRrb (ORCPT ); Mon, 22 Jul 2013 13:47:31 -0400 Received: from mail-qe0-f51.google.com ([209.85.128.51]:63885 "EHLO mail-qe0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756027Ab3GVRra (ORCPT ); Mon, 22 Jul 2013 13:47:30 -0400 Received: by mail-qe0-f51.google.com with SMTP id a11so3862979qen.24 for ; Mon, 22 Jul 2013 10:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=nxDoEDlUvHaA34sKD8u0E06dRzRejB5knV6w0vR4Cvc=; b=SdqzraWYMI/dKOrz1sTkgi1G60UT3OOJrKR5vtZIRk7Y1Ylnac4hhOaZ9STutA9TuK YT08U7PvBUsSB2Rhb0LmLFc2HKOVUT1brGvfBXufNnLlgOXJLe/1cApKRa2Ewx6B3cn6 /8gnRuMeduVwtPEWpgEUkq8It08bNVEhb0Qk148GYBl6ViPycvHD3QBEr+VnTtero2tz 1ZWB0mtJ4eOghaToBA9j4RuMM2AHc7HsWpKXV1VcPM8f/UOONj/zFsp3tYeVCditDPv/ viWLwIjv8QPWF4LT2jVyXnScdwN5PuXPdNcgRnr6C+Imnqie7dmQTKbEzqf0A6Gh8Lzi qT6w== X-Received: by 10.49.107.105 with SMTP id hb9mr12875743qeb.74.1374515249614; Mon, 22 Jul 2013 10:47:29 -0700 (PDT) Received: from nix.cleftstone.net ([64.9.42.64]) by mx.google.com with ESMTPSA id a4sm2944490qai.3.2013.07.22.10.47.27 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 22 Jul 2013 10:47:28 -0700 (PDT) From: scott.lovenberg@gmail.com To: jlayton@redhat.com Cc: Scott Lovenberg , gang.chen@asianux.com, sfrench@samba.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH] RFC cifs-utils: Use autoconf to get kernel headers Date: Mon, 22 Jul 2013 13:47:23 -0400 Message-Id: <1374515243-21624-1-git-send-email-scott.lovenberg@gmail.com> X-Mailer: git-send-email 1.8.1.4 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Scott Lovenberg This is an RFC for how we'd use autoconf to get the Linux kernel headers in include/uapi/linux/cifs.h. If this is the correct approach, I'll formalize this patch. I've never played with autoconf before so this is completely untested but should (read: might) probably work. Signed-off-by: Scott Lovenberg --- configure.ac | 3 +++ mount.cifs.c | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index b5f7c49..708fdeb 100644 --- a/configure.ac +++ b/configure.ac @@ -111,6 +111,9 @@ AC_SUBST(RT_LDADD) # Checks for header files. AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h inttypes.h limits.h mntent.h netdb.h stddef.h stdint.h stdbool.h stdlib.h stdio.h errno.h string.h strings.h sys/mount.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h], , [AC_MSG_ERROR([necessary header(s) not found])]) +# Check for linux's cifs.h header that defines string lengths. +AC_CHECK_HEADER([linux/cifs.h], ,[AC_MSG_WARN([cifs kernel header not found. Using internal values.])]) + # do we have sys/fsuid.h and setfsuid()? AC_CHECK_HEADERS([sys/fsuid.h]) AC_CHECK_FUNC(setfsuid, , [AC_MSG_ERROR([System does not support setfsuid()])]) diff --git a/mount.cifs.c b/mount.cifs.c index 77ea0f8..0fca0a9 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -62,6 +62,9 @@ #include "mount.h" #include "util.h" #include "resolve_host.h" +#ifdef HAVE_LINUX_CIFS_H +#include +#endif /* HAVE_LINUX_CIFS_h */ #ifndef MS_MOVE #define MS_MOVE 8192 @@ -91,16 +94,24 @@ /* Max length of the share name portion of a UNC. Share names over 80 * characters cannot be accessed via commandline in Windows 2000/XP. */ -#define MAX_SHARE_LEN 256 +#ifndef MAX_SHARE_SIZE +#define MAX_SHARE_SIZE 256 +#endif /* Max user name length. */ +#ifndef MAX_USERNAME_SIZE #define MAX_USERNAME_SIZE 256 +#endif /* Max domain size. */ -#define MAX_DOMAIN_SIZE 256 +#ifndef MAX_DOMAINNAME_SIZE +#define MAX_DOMAINNAME_SIZE 256 +#endif /* Max password size. */ -#define MOUNT_PASSWD_SIZE 512 +#ifndef MAX_PASSWORD_SIZE +#define MAX_PASSWORD_SIZE 512 +#endif @@ -176,12 +187,12 @@ struct parsed_mount_info { unsigned long flags; char host[NI_MAXHOST + 1]; - char share[MAX_SHARE_LEN + 1]; + char share[MAX_SHARE_SIZE + 1]; char prefix[PATH_MAX + 1]; char options[MAX_OPTIONS_LEN]; - char domain[MAX_DOMAIN_SIZE + 1]; + char domain[MAX_DOMAINNAME_SIZE + 1]; char username[MAX_USERNAME_SIZE + 1]; - char password[MOUNT_PASSWD_SIZE + 1]; + char password[MAX_PASSWORD_SIZE + 1]; char addrlist[MAX_ADDR_LIST_LEN]; unsigned int got_user:1; unsigned int got_password:1; @@ -1766,13 +1777,13 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info, } if (!parsed_info->got_password) { - char tmp_pass[MOUNT_PASSWD_SIZE + 1]; + char tmp_pass[MAX_PASSWORD_SIZE + 1]; char *prompt = NULL; if(asprintf(&prompt, "Password for %s@%s: ", parsed_info->username, orig_dev) < 0) prompt = NULL; - if (get_password(prompt ? prompt : "Password: ", tmp_pass, MOUNT_PASSWD_SIZE + 1)) { + if (get_password(prompt ? prompt : "Password: ", tmp_pass, MAX_PASSWORD_SIZE + 1)) { rc = set_password(parsed_info, tmp_pass); } else { fprintf(stderr, "Error reading password, exiting\n");