Ticket #20862: screen-4.0.3-snowleopard.patch

File screen-4.0.3-snowleopard.patch, 11.0 KB (added by mccune.jeff@…, 15 years ago)

Patch to compile screen-4.0.3 in Mac OS X Snow Leopard

  • Makefile.in

    diff --git a/Makefile.in b/Makefile.in
    index db683ac..14ba5db 100644
    a b install_bin: .version screen 
    7979        -if [ -f $(DESTDIR)$(bindir)/screen ] && [ ! -f $(DESTDIR)$(bindir)/screen.old ]; then mv $(DESTDIR)$(bindir)/screen $(DESTDIR)$(bindir)/screen.old; fi
    8080        rm -f $(DESTDIR)$(bindir)/screen
    8181        (cd $(DESTDIR)$(bindir) && ln -sf $(SCREEN) screen)
    82         cp $(srcdir)/utf8encodings/?? $(DESTDIR)$(SCREENENCODINGS)
     82        cp $(srcdir)/utf8encodings/?? $(DSTROOT)$(SCREENENCODINGS)
    8383
    8484###############################################################################
    8585install: installdirs install_bin
    install: installdirs install_bin 
    9595
    9696installdirs:
    9797# Path leading to ETCSCREENRC and Socketdirectory not checked.
    98         $(srcdir)/etc/mkinstalldirs $(DESTDIR)$(bindir) $(DESTDIR)$(SCREENENCODINGS)
     98        $(srcdir)/etc/mkinstalldirs $(DESTDIR)$(bindir) $(DSTROOT)$(SCREENENCODINGS)
    9999        cd doc ; $(MAKE) installdirs
    100100
    101101uninstall: .version
    tty.c: tty.sh 
    122122        sh $(srcdir)/tty.sh tty.c
    123123
    124124comm.h: comm.c comm.sh config.h
    125         AWK=$(AWK) CC="$(CC) $(CFLAGS)" srcdir=${srcdir} sh $(srcdir)/comm.sh
     125        AWK=$(AWK) srcdir=${srcdir} sh $(srcdir)/comm.sh
    126126
    127127osdef.h: osdef.sh config.h osdef.h.in
    128128        CPP="$(CPP) $(CPPFLAGS)" srcdir=${srcdir} sh $(srcdir)/osdef.sh
  • config.h.in

    diff --git a/config.h.in b/config.h.in
    index 4327855..a32d66b 100644
    a b  
    208208 * If screen is installed with permissions to update /etc/utmp (such
    209209 * as if it is installed set-uid root), define UTMPOK.
    210210 */
    211 #define UTMPOK
     211#undef UTMPOK
    212212
    213213/* Set LOGINDEFAULT to one (1)
    214214 * if you want entries added to /etc/utmp by default, else set it to
    215215 * zero (0).
    216216 * LOGINDEFAULT will be one (1) whenever LOGOUTOK is undefined!
    217217 */
    218 #define LOGINDEFAULT    1
     218#undef LOGINDEFAULT
    219219
    220220/* Set LOGOUTOK to one (1)
    221221 * if you want the user to be able to log her/his windows out.
     
    231231 * Set CAREFULUTMP to one (1) if you want that users have at least one
    232232 * window per screen session logged in.
    233233 */
    234 #define LOGOUTOK 1
     234#undef LOGOUTOK
    235235#undef CAREFULUTMP
    236236
    237237
  • configure

    diff --git a/configure b/configure
    index 75675fc..c9dcbd3 100755
    a b cat >>conftest.$ac_ext <<_ACEOF 
    55725572
    55735573#include <time.h> /* to get time_t on SCO */
    55745574#include <sys/types.h>
    5575 #if defined(SVR4) && !defined(DGUX)
     5575#if (defined(SVR4) || defined(__APPLE__)) && !defined(DGUX)
    55765576#include <utmpx.h>
    55775577#define utmp utmpx
    55785578#else
    cat >>conftest.$ac_ext <<_ACEOF 
    55815581#ifdef __hpux
    55825582#define pututline _pututline
    55835583#endif
     5584#ifdef __APPLE__
     5585#define pututline pututxline
     5586#define getutent getutxent
     5587#endif
    55845588
    55855589int
    55865590main ()
  • process.c

    diff --git a/process.c b/process.c
    index 7f1a6e1..8e52b02 100644
    a b char *data; /* dummy */ 
    54665466      *buf = 0;
    54675467      return;
    54685468    }
    5469   act.nr = (int)data;
     5469  act.nr = (int)(intptr_t)data;
    54705470  act.args = noargs;
    54715471  act.argl = 0;
    54725472  DoAction(&act, -1);
  • pty.c

    diff --git a/pty.c b/pty.c
    index f89d44c..38e9709 100644
    a b  
    3434#endif
    3535
    3636/* for solaris 2.1, Unixware (SVR4.2) and possibly others */
    37 #ifdef HAVE_SVR4_PTYS
     37#if defined(HAVE_SVR4_PTYS) && !defined(__APPLE__)
    3838# include <sys/stropts.h>
    3939#endif
    4040
  • screen.c

    diff --git a/screen.c b/screen.c
    index 70741df..c980514 100644
    a b  
    101101
    102102#include "logfile.h"    /* islogfile, logfflush */
    103103
     104#ifdef __APPLE__
     105#include <vproc.h>
     106#include <vproc_priv.h>
     107#endif
     108
    104109#ifdef DEBUG
    105110FILE *dfp;
    106111#endif
    char **av; 
    929934        Panic(0, "No $SCREENDIR with multi screens, please.");
    930935#endif
    931936    }
     937#ifdef __APPLE__
     938    else if (!multi && real_uid == eff_uid) {
     939      static char DarwinSockDir[PATH_MAX];
     940      if (confstr(_CS_DARWIN_USER_TEMP_DIR, DarwinSockDir, sizeof(DarwinSockDir))) {
     941      strlcat(DarwinSockDir, ".screen", sizeof(DarwinSockDir));
     942      SockDir = DarwinSockDir;
     943      }
     944    }
     945#endif /* __APPLE__ */
     946
    932947#ifdef MULTIUSER
    933948  if (multiattach)
    934949    {
    char **av; 
    12111226  freopen("/dev/null", "w", stderr);
    12121227  debug("-- screen.back debug started\n");
    12131228
     1229#ifdef __APPLE__
     1230       if (_vprocmgr_detach_from_console(0) != NULL)
     1231          errx(1, "can't detach from console");
     1232#endif
     1233
    12141234  /*
    12151235   * This guarantees that the session owner is listed, even when we
    12161236   * start detached. From now on we should not refer to 'LoginName'
  • new file vproc_priv.h

    diff --git a/vproc_priv.h b/vproc_priv.h
    new file mode 100644
    index 0000000..b691c22
    - +  
     1#ifndef _VPROC_PRIVATE_H_
     2#define _VPROC_PRIVATE_H_
     3/*
     4 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
     5 *
     6 * @APPLE_APACHE_LICENSE_HEADER_START@
     7 *
     8 * Licensed under the Apache License, Version 2.0 (the "License");
     9 * you may not use this file except in compliance with the License.
     10 * You may obtain a copy of the License at
     11 *
     12 *     http://www.apache.org/licenses/LICENSE-2.0
     13 *
     14 * Unless required by applicable law or agreed to in writing, software
     15 * distributed under the License is distributed on an "AS IS" BASIS,
     16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     17 * See the License for the specific language governing permissions and
     18 * limitations under the License.
     19 *
     20 * @APPLE_APACHE_LICENSE_HEADER_END@
     21 */
     22
     23#include <Availability.h>
     24#include <sys/types.h>
     25#include <sys/cdefs.h>
     26#include <sys/syslog.h>
     27#include <sys/time.h>
     28#include <stdbool.h>
     29#include <launch.h>
     30#include <vproc.h>
     31#include <uuid/uuid.h>
     32
     33#ifndef VPROC_HAS_TRANSACTIONS
     34        #define VPROC_HAS_TRANSACTIONS
     35#endif
     36
     37__BEGIN_DECLS
     38
     39#pragma GCC visibility push(default)
     40
     41/* DO NOT use this. This is a hack for 'launchctl' */
     42#define VPROC_MAGIC_UNLOAD_SIGNAL       0x4141504C
     43/* DO NOT use this. This is a hack for 'loginwindow' */
     44#define VPROC_MAGIC_TRYKILL_SIGNAL      0x6161706C
     45
     46typedef enum {
     47        VPROC_GSK_LAST_EXIT_STATUS = 1,
     48        VPROC_GSK_GLOBAL_ON_DEMAND,
     49        VPROC_GSK_MGR_UID,
     50        VPROC_GSK_MGR_PID,
     51        VPROC_GSK_IS_MANAGED,
     52        VPROC_GSK_MGR_NAME,
     53        VPROC_GSK_BASIC_KEEPALIVE,
     54        VPROC_GSK_START_INTERVAL,
     55        VPROC_GSK_IDLE_TIMEOUT,
     56        VPROC_GSK_EXIT_TIMEOUT,
     57        VPROC_GSK_ENVIRONMENT,
     58        VPROC_GSK_ALLJOBS,
     59        VPROC_GSK_GLOBAL_LOG_MASK,
     60        VPROC_GSK_GLOBAL_UMASK,
     61        VPROC_GSK_ABANDON_PROCESS_GROUP,
     62        VPROC_GSK_TRANSACTIONS_ENABLED,
     63        VPROC_GSK_WEIRD_BOOTSTRAP,
     64        VPROC_GSK_WAITFORDEBUGGER,
     65        VPROC_GSK_SECURITYSESSION,
     66        VPROC_GSK_SHUTDOWN_DEBUGGING,
     67        VPROC_GSK_VERBOSE_BOOT,
     68        VPROC_GSK_PERUSER_SUSPEND,
     69        VPROC_GSK_PERUSER_RESUME,
     70        VPROC_GSK_JOB_OVERRIDES_DB,
     71        VPROC_GSK_JOB_CACHE_DB,
     72        VPROC_GSK_EMBEDDEDROOTEQUIVALENT,
     73} vproc_gsk_t;
     74
     75typedef unsigned int vproc_flags_t;
     76/* For _vproc_kickstart_by_label() -- instructs launchd to kickstart the job to stall before exec(2). */
     77#define VPROCFLAG_STALL_JOB_EXEC        1 << 1
     78
     79vproc_t vprocmgr_lookup_vproc(const char *label);
     80vproc_t vproc_retain(vproc_t vp);
     81void vproc_release(vproc_t vp);
     82
     83vproc_err_t vproc_swap_integer(vproc_t vp, vproc_gsk_t key, int64_t *inval, int64_t *outval);
     84vproc_err_t vproc_swap_complex(vproc_t vp, vproc_gsk_t key, launch_data_t inval, launch_data_t *outval);
     85vproc_err_t vproc_swap_string(vproc_t vp, vproc_gsk_t key, const char *instr, char **outstr);
     86
     87vproc_err_t _vproc_get_last_exit_status(int *wstatus);
     88vproc_err_t _vproc_set_global_on_demand(bool val);
     89
     90typedef void (*_vprocmgr_log_drain_callback_t)(struct timeval *when, pid_t from_pid, pid_t about_pid, uid_t sender_uid, gid_t sender_gid, int priority, const char *from_name, const char *about_name, const char *session_name, const char *msg);
     91
     92vproc_err_t _vprocmgr_log_drain(vproc_t vp, pthread_mutex_t *optional_mutex_around_callback, _vprocmgr_log_drain_callback_t func);
     93
     94vproc_err_t _vproc_send_signal_by_label(const char *label, int sig);
     95vproc_err_t _vproc_kickstart_by_label(const char *label, pid_t *out_pid, mach_port_t *out_port_name, mach_port_t *out_obsrvr_port, vproc_flags_t flags);
     96vproc_err_t _vproc_wait_by_label(const char *label, int *out_wstatus);
     97
     98void _vproc_log(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3)));
     99void _vproc_log_error(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3)));
     100void _vproc_logv(int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 3, 0)));
     101
     102#define VPROCMGR_SESSION_LOGINWINDOW    "LoginWindow"
     103#define VPROCMGR_SESSION_BACKGROUND             "Background"
     104#define VPROCMGR_SESSION_AQUA                   "Aqua"
     105#define VPROCMGR_SESSION_STANDARDIO             "StandardIO"
     106#define VPROCMGR_SESSION_SYSTEM                 "System"
     107
     108vproc_err_t _vprocmgr_move_subset_to_user(uid_t target_user, const char *session_type, uint64_t flags);
     109vproc_err_t _vprocmgr_switch_to_session(const char *target_session, vproc_flags_t flags);
     110vproc_err_t _vprocmgr_detach_from_console(vproc_flags_t flags);
     111
     112void _vproc_standby_begin(void)                                                                                                                         __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     113void _vproc_standby_end(void)                                                                                                                           __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     114size_t _vproc_standby_count(void)                                                                                                                       __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     115size_t _vproc_standby_timeout(void)                                                                                                                     __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     116
     117kern_return_t _vproc_transaction_count_for_pid(pid_t p, int32_t *count, bool *condemned)        __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     118bool _vproc_pid_is_managed(pid_t p)                                                                                                                     __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     119void _vproc_transaction_try_exit(int status)                                                                                            __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     120void _vproc_transaction_begin(void)                                                                                                                     __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     121void _vproc_transaction_end(void)                                                                                                                       __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     122size_t _vproc_transaction_count(void)                                                                                                           __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA);
     123
     124#pragma GCC visibility pop
     125
     126__END_DECLS
     127
     128#endif
  • window.c

    diff --git a/window.c b/window.c
    index 3b60ae0..5cae839 100644
    a b  
    2525#include <sys/stat.h>
    2626#include <signal.h>
    2727#include <fcntl.h>
     28#include <unistd.h>
    2829#ifndef sun
    2930# include <sys/ioctl.h>
    3031#endif
    char **args, *ttyn; 
    13871388  return pid;
    13881389}
    13891390
     1391#ifdef RUN_LOGIN
     1392/*
     1393 * All of the logic to maintain utmpx is now built into /usr/bin/login, so
     1394 * all we need to do is call it, and pass the shell command to it.
     1395 */
     1396extern char *LoginName;
     1397
     1398static int
     1399run_login(const char *path, char *const argv[], char *const envp[])
     1400{
     1401  const char *shargs[MAXARGS + 1 + 3];
     1402  const char **fp, **tp;
     1403
     1404  if (access(path, X_OK) < 0)
     1405    return -1;
     1406  shargs[0] = "login";
     1407  shargs[1] = (*argv[0] == '-') ? "-pfq" : "-pflq";
     1408  shargs[2] = LoginName;
     1409  shargs[3] = path;
     1410  fp = (const char **)argv + 1;
     1411  tp = shargs + 4;
     1412  /* argv has already been check for length */
     1413  while ((*tp++ = *fp++) != NULL) {}
     1414  /* shouldn't return unless there was an error */
     1415  return (execve("/usr/bin/login", (char *const*)shargs, envp));
     1416}
     1417
     1418/* replace the following occurrences of execve() with run_login() */
     1419#define execve run_login
     1420
     1421#endif /* RUN_LOGIN */
     1422
    13901423void
    13911424execvpe(prog, args, env)
    13921425char *prog, **args, **env;