From patchwork Sun Mar 21 19:20:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 87287 Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2LJLGV5013504 for ; Sun, 21 Mar 2010 19:21:51 GMT Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 119D0AD0E9; Sun, 21 Mar 2010 13:21:02 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=3.8 tests=AWL, BAYES_00, NO_MORE_FUNN, SPF_PASS autolearn=no version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from cdptpa-omtalb.mail.rr.com (cdptpa-omtalb.mail.rr.com [75.180.132.122]) by lists.samba.org (Postfix) with ESMTP id CB584AD225 for ; Sun, 21 Mar 2010 13:20:47 -0600 (MDT) X-Authority-Analysis: v=1.0 c=1 a=JMUGtl3Gj4YA:10 a=20KFwNOVAAAA:8 a=H2nfmgSy9OaFZZDrTXAA:9 a=n1-rDjduLnQClP2JXjEA:7 a=MoZHoH5p9m-WAshWKZjCFmWwU-sA:4 a=jEp0ucaQiEUA:10 X-Cloudmark-Score: 0 X-Originating-IP: 71.70.153.3 Received: from [71.70.153.3] ([71.70.153.3:53430] helo=mail.poochiereds.net) by cdptpa-oedge02.mail.rr.com (envelope-from ) (ecelerity 2.2.2.39 r()) with ESMTP id 65/46-06757-D8176AB4; Sun, 21 Mar 2010 19:20:46 +0000 Received: by mail.poochiereds.net (Postfix, from userid 4447) id 0EE2B5805C; Sun, 21 Mar 2010 15:20:28 -0400 (EDT) From: Jeff Layton To: linux-cifs-client@lists.samba.org Date: Sun, 21 Mar 2010 15:20:27 -0400 Message-Id: <1269199227-21446-11-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: References: Subject: [linux-cifs-client] [PATCH 10/10] mount.cifs: don't use exit(3) in get_password_from_file X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 21 Mar 2010 19:21:52 +0000 (UTC) diff --git a/mount.cifs.c b/mount.cifs.c index e6ab7cc..ca4f4e4 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -400,7 +400,7 @@ static int get_password_from_file(int file_descript, char * filename) if (mountpassword == NULL) { fprintf(stderr, "malloc failed\n"); - exit(EX_SYSERR); + return EX_SYSERR; } if(filename != NULL) { @@ -408,13 +408,13 @@ static int get_password_from_file(int file_descript, char * filename) if (rc) { fprintf(stderr, "mount.cifs failed: access check of %s failed: %s\n", filename, strerror(errno)); - exit(EX_SYSERR); + return EX_SYSERR; } file_descript = open(filename, O_RDONLY); if(file_descript < 0) { fprintf(stderr, "mount.cifs failed. %s attempting to open password file %s\n", strerror(errno),filename); - exit(EX_SYSERR); + return EX_SYSERR; } } /* else file already open and fd provided */ @@ -425,7 +425,7 @@ static int get_password_from_file(int file_descript, char * filename) fprintf(stderr, "mount.cifs failed. Error %s reading password file\n",strerror(errno)); if(filename != NULL) close(file_descript); - exit(EX_SYSERR); + return EX_SYSERR; } else if(rc == 0) { if(mountpassword[0] == 0) { if(verboseflag) @@ -1308,7 +1308,9 @@ int main(int argc, char ** argv) } break; case 'S': - get_password_from_file(0 /* stdin */,NULL); + rc = get_password_from_file(0 /* stdin */,NULL); + if (rc) + goto mount_exit; break; case 't': break; @@ -1368,9 +1370,13 @@ int main(int argc, char ** argv) got_password = 1; } } else if (getenv("PASSWD_FD")) { - get_password_from_file(atoi(getenv("PASSWD_FD")),NULL); + rc = get_password_from_file(atoi(getenv("PASSWD_FD")),NULL); + if (rc) + goto mount_exit; } else if (getenv("PASSWD_FILE")) { - get_password_from_file(0, getenv("PASSWD_FILE")); + rc = get_password_from_file(0, getenv("PASSWD_FILE")); + if (rc) + goto mount_exit; } if (orgoptions && parse_options(&orgoptions, &flags)) {