summaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Expand)Author
2020-10-29Command: Add unittestsSean Molenaar
2020-10-12Allow titles to be nullSean Molenaar
2020-10-10Fix usage of at() in unittestsSean Molenaar
2020-10-05Define microtime as stringSean Molenaar
2020-10-02fix incorrect cron recommendationanoy
2020-09-29Add feed autodiscoverySean Molenaar
2020-09-29OPML export command and fixesSean Molenaar
2020-09-29Fix repair step and test itSean Molenaar
2020-09-27Create V2 mapper, Service and management commandsSean Molenaar
2020-09-25Move to nextcloud config and update phpunitSean Molenaar
2020-09-17run phpcbfBenjamin Brahmer
2020-09-17fix config testBenjamin Brahmer
2020-08-29fix import with invalid guid_hashBenjamin Brahmer
2020-08-14Update to new BackgroudJob logicBenjamin Brahmer
2020-03-09Add test to ensure that null will emit a exceptionDaniel Kesselberg
2020-02-16Basic Media-RSS support (#599)Éloi Rivard
2019-12-27Update httpLastModified from the feed response (#594)kesselb
2019-12-25Update for nextcloud 18 (#593)Benjamin Brahmer
2019-12-24Reimplement full-text scraping (#563)DriverXX
2019-11-16Get content:encoded of item if available (#565)b_b
2019-03-26Fix xkcd commicsSean Molenaar
2019-03-21Allow empty-ish lastmodified and clean up FeedFetcher Test (#458)Sean Molenaar
2019-03-17fix/allow CDATA encoding (#428)Sean Molenaar
2019-03-12Fix email and password not being encodedSean Molenaar
2019-03-12Catch FeedIO reader exception.Sean Molenaar
2019-03-06Fix references to old manual versions and general cleanup (#404)Sean Molenaar
2019-03-06Fix generation commands and make them available in ./occ (#402)Sean Molenaar
2019-02-23Allow empty update timeSean Molenaar
2019-01-31Fix mismatched interfaceSean Molenaar
2019-01-30Parser: Switch to feedIO for parsing instead of picoFeedSean Molenaar
2018-12-04use magic class constant instead of classname stringsDaniel Opitz
2018-10-04fix FeedTest and revert packacge-lockBenjamin Brahmer
2018-10-02Merge pull request #283 from danopz/entity-methodsSean Molenaar
2018-10-02Put back old tests for stable nextcloud versionSean Molenaar
2018-10-01dont call parent constructor for fixture classes, revert php 7 requirementDaniel Opitz
2018-09-28add setters + getters to Folder and Item entities, fixed unit tests, rearrang...Daniel Opitz
2018-09-28fixed feed testsDaniel Opitz
2018-09-28add getters + setters for feed entityDaniel Opitz
2018-07-01test(api): adapt tests to previous changeDavid Guillot
2018-03-27Core: Fix compatibility with nextcloud codestyle (#280)Sean Molenaar
2018-03-18Unit: Fix unittests (#278)Sean Molenaar
2017-08-14Split binary to booleans (#203)Daniel Opitz
2017-06-06Fix travis build (#178)Daniel Schaal
2017-03-21fix unit testsBernhard Posselt
2017-01-04Add postprocessor for getting lwn subscriber articles (#72)Robin Appelman
2017-01-04Add updatedDate to item model (#81)Daniel Schaal
2016-11-18Throw ServiceNotFoundException when marking non-existent item as read (#61)Daniel Schaal
2016-11-18Use createMock() instead of deprecated getMock() (#62)Daniel Schaal
2016-10-02revertBernhard Posselt
2016-10-01Add updatedDate to item model (#43)Daniel Schaal
24' href='#n524'>524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878
/*
 * linux/kernel/ptrace.c
 *
 * (C) Copyright 1999 Linus Torvalds
 *
 * Common interfaces for "ptrace()" which we do not want
 * to continually duplicate across every architecture.
 */

#include <linux/capability.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include <linux/ptrace.h>
#include <linux/security.h>
#include <linux/signal.h>
#include <linux/audit.h>
#include <linux/pid_namespace.h>
#include <linux/syscalls.h>
#include <linux/uaccess.h>
#include <linux/regset.h>


/*
 * ptrace a task: make the debugger its new parent and
 * move it to the ptrace list.
 *
 * Must be called with the tasklist lock write-held.
 */
void __ptrace_link(struct task_struct *child, struct task_struct *new_parent)
{
	BUG_ON(!list_empty(&child->ptrace_entry));
	list_add(&child->ptrace_entry, &new_parent->ptraced);
	child->parent = new_parent;
}

/*
 * Turn a tracing stop into a normal stop now, since with no tracer there
 * would be no way to wake it up with SIGCONT or SIGKILL.  If there was a
 * signal sent that would resume the child, but didn't because it was in
 * TASK_TRACED, resume it now.
 * Requires that irqs be disabled.
 */
static void ptrace_untrace(struct task_struct *child)
{
	spin_lock(&child->sighand->siglock);
	if (task_is_traced(child)) {
		/*
		 * If the group stop is completed or in progress,
		 * this thread was already counted as stopped.
		 */
		if (child->signal->flags & SIGNAL_STOP_STOPPED ||
		    child->signal->group_stop_count)
			__set_task_state(child, TASK_STOPPED);
		else
			signal_wake_up(child, 1);
	}
	spin_unlock(&child->sighand->siglock);
}

/*
 * unptrace a task: move it back to its original parent and
 * remove it from the ptrace list.
 *
 * Must be called with the tasklist lock write-held.
 */
void __ptrace_unlink(struct task_struct *child)
{
	BUG_ON(!child->ptrace);

	child->ptrace = 0;
	child->parent = child->real_parent;
	list_del_init(&child->ptrace_entry);

	if (task_is_traced(child))
		ptrace_untrace(child);
}

/*
 * Check that we have indeed attached to the thing..
 */
int ptrace_check_attach(struct task_struct *child, int kill)
{
	int ret = -ESRCH;

	/*
	 * We take the read lock around doing both checks to close a
	 * possible race where someone else was tracing our child and
	 * detached between these two checks.  After this locked check,
	 * we are sure that this is our traced child and that can only
	 * be changed by us so it's not changing right after this.
	 */
	read_lock(&tasklist_lock);
	if ((child->ptrace & PT_PTRACED) && child->parent == current) {
		ret = 0;
		/*
		 * child->sighand can't be NULL, release_task()
		 * does ptrace_unlink() before __exit_signal().
		 */
		spin_lock_irq(&child->sighand->siglock);
		if (task_is_stopped(child))
			child->state = TASK_TRACED;
		else if (!task_is_traced(child) && !kill)
			ret = -ESRCH;
		spin_unlock_irq(&child->sighand->siglock);
	}
	read_unlock(&tasklist_lock);

	if (!ret && !kill)
		ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH;

	/* All systems go.. */
	return ret;
}

int __ptrace_may_access(struct task_struct *task, unsigned int mode)
{
	const struct cred *cred = current_cred(), *tcred;

	/* May we inspect the given task?
	 * This check is used both for attaching with ptrace
	 * and for allowing access to sensitive information in /proc.
	 *
	 * ptrace_attach denies several cases that /proc allows
	 * because setting up the necessary parent/child relationship
	 * or halting the specified task is impossible.
	 */
	int dumpable = 0;
	/* Don't let security modules deny introspection */
	if (task == current)
		return 0;
	rcu_read_lock();
	tcred = __task_cred(task);
	if ((cred->uid != tcred->euid ||
	     cred->uid != tcred->suid ||
	     cred->uid != tcred->uid  ||
	     cred->gid != tcred->egid ||
	     cred->gid != tcred->sgid ||
	     cred->gid != tcred->gid) &&
	    !capable(CAP_SYS_PTRACE)) {
		rcu_read_unlock();
		return -EPERM;
	}
	rcu_read_unlock();
	smp_rmb();
	if (task->mm)
		dumpable = get_dumpable(task->mm);
	if (!dumpable && !capable(CAP_SYS_PTRACE))
		return -EPERM;

	return security_ptrace_access_check(task, mode);
}

bool ptrace_may_access(struct task_struct *task, unsigned int mode)
{
	int err;
	task_lock(task);
	err = __ptrace_may_access(task, mode);
	task_unlock(task);
	return !err;
}

int ptrace_attach(struct task_struct *task)
{
	int retval;

	audit_ptrace(task);

	retval = -EPERM;
	if (unlikely(task->flags & PF_KTHREAD))
		goto out;
	if (same_thread_group(task, current))
		goto out;

	/*
	 * Protect exec's credential calculations against our interference;
	 * interference; SUID, SGID and LSM creds get determined differently
	 * under ptrace.
	 */
	retval = -ERESTARTNOINTR;
	if (mutex_lock_interruptible(&task->signal->cred_guard_mutex))
		goto out;

	task_lock(task);
	retval = __ptrace_may_access(task, PTRACE_MODE_ATTACH);
	task_unlock(task);
	if (retval)
		goto unlock_creds;

	write_lock_irq(&tasklist_lock);
	retval = -EPERM;
	if (unlikely(task->exit_state))
		goto unlock_tasklist;
	if (task->ptrace)
		goto unlock_tasklist;

	task->ptrace = PT_PTRACED;
	if