summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-07-14 07:34:45 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-07-14 07:34:45 +0000
commiteec2d3df379716e72d6e7a8316fcb65b89fb13eb (patch)
treeced15250c8f4f5103a1c6de3495f4eb3115c159b /pp_sys.c
parent0f5feb8dcd2bdb835f78952aa842c128d6c5b2aa (diff)
downloadperl-eec2d3df379716e72d6e7a8316fcb65b89fb13eb.tar.gz
merge changes#1423,1465 from maintbranch; checkin two missed files
from earlier changes#1461,1478 p4raw-link: @1478 on //depot/perl: 1d84e8dfc14d5303f4e9e567bd263f6b4d88e584 p4raw-link: @1465 on //depot/maint-5.004/perl: 5c79ff06c1b2e0ce9610857baca341a322e96624 p4raw-link: @1461 on //depot/perl: 8782bef2aa2ca158fdd0d7436e68ae3ac2b01ff7 p4raw-link: @1423 on //depot/maint-5.004/perl: 9b114077a050865568261ebf91069aa7983019c3 p4raw-id: //depot/perl@1488
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 16e39e2e3d..fe75220d38 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -499,6 +499,11 @@ PP(pp_umask)
TAINT_PROPER("umask");
XPUSHi(anum);
#else
+ /* Only DIE if trying to restrict permissions on `user' (self).
+ * Otherwise it's harmless and more useful to just return undef
+ * since 'group' and 'other' concepts probably don't exist here. */
+ if (MAXARG >= 1 && (POPi & 0700))
+ DIE("umask not implemented");
XPUSHs(&sv_undef);
#endif
RETURN;
@@ -1267,7 +1272,7 @@ PP(pp_sysread)
#ifdef HAS_SOCKET
if (op->op_type == OP_RECV) {
char namebuf[MAXPATHLEN];
-#if defined(VMS_DO_SOCKETS) && defined(DECCRTL_SOCKETS)
+#if (defined(VMS_DO_SOCKETS) && defined(DECCRTL_SOCKETS)) || defined(MPE)
bufsize = sizeof (struct sockaddr_in);
#else
bufsize = sizeof namebuf;
@@ -1761,18 +1766,47 @@ PP(pp_bind)
{
djSP;
#ifdef HAS_SOCKET
+#ifdef MPE /* Requires PRIV mode to bind() to ports < 1024 */
+ extern GETPRIVMODE();
+ extern GETUSERMODE();
+#endif
SV *addrsv = POPs;
char *addr;
GV *gv = (GV*)POPs;
register IO *io = GvIOn(gv);
STRLEN len;
+ int bind_ok = 0;
+#ifdef MPE
+ int mpeprivmode = 0;
+#endif
if (!io || !IoIFP(io))
goto nuts;
addr = SvPV(addrsv, len);
TAINT_PROPER("bind");
- if (PerlSock_bind(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len) >= 0)
+#ifdef MPE /* Deal with MPE bind() peculiarities */
+ if (((struct sockaddr *)addr)->sa_family == AF_INET) {
+ /* The address *MUST* stupidly be zero. */
+ ((struct sockaddr_in *)addr)->sin_addr.s_addr = INADDR_ANY;
+ /* PRIV mode is required to bind() to ports < 1024. */
+ if (((struct sockaddr_in *)addr)->sin_port < 1024 &&
+ ((struct sockaddr_in *)addr)->sin_port > 0) {
+ GETPRIVMODE(); /* If this fails, we are aborted by MPE/iX. */
+ mpeprivmode = 1;
+ }
+ }
+#endif /* MPE */
+ if (PerlSock_bind(PerlIO_fileno(IoIFP(io)),
+ (struct sockaddr *)addr, len) >= 0)
+ bind_ok = 1;
+
+#ifdef MPE /* Switch back to USER mode */
+ if (mpeprivmode)
+ GETUSERMODE();
+#endif /* MPE */
+
+ if (bind_ok)
RETPUSHYES;
else
RETPUSHUNDEF;